{"action":"opened","issue":{"url":"https://api.github.com/repos/SheffieldML/GPy/issues/631","repository_url":"https://api.github.com/repos/SheffieldML/GPy","labels_url":"https://api.github.com/repos/SheffieldML/GPy/issues/631/labels{/name}","comments_url":"https://api.github.com/repos/SheffieldML/GPy/issues/631/comments","events_url":"https://api.github.com/repos/SheffieldML/GPy/issues/631/events","html_url":"https://github.com/SheffieldML/GPy/issues/631","id":317822548,"number":631,"title":"Logit link for Binomial likelihood and specify prior on hyper-parameters","user":{"login":"checorh","id":8077265,"avatar_url":"https://avatars2.githubusercontent.com/u/8077265?v=4","gravatar_id":"","url":"https://api.github.com/users/checorh","html_url":"https://github.com/checorh","followers_url":"https://api.github.com/users/checorh/followers","following_url":"https://api.github.com/users/checorh/following{/other_user}","gists_url":"https://api.github.com/users/checorh/gists{/gist_id}","starred_url":"https://api.github.com/users/checorh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/checorh/subscriptions","organizations_url":"https://api.github.com/users/checorh/orgs","repos_url":"https://api.github.com/users/checorh/repos","events_url":"https://api.github.com/users/checorh/events{/privacy}","received_events_url":"https://api.github.com/users/checorh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-25T23:00:38Z","updated_at":"2018-04-25T23:00:38Z","closed_at":null,"author_association":"NONE","body":"Hi there!\r\n\r\nI am PhD student in Statistics from UC Santa Barbara. Currently, I am trying to fit a latent GP using the Laplace approximation where the data likelihood is Binomial  (Thanks for sharing your work via Github!)\r\n\r\nBelow is an example of the code that I am using:\r\n\r\n1. Load packages\r\n```\r\n%pylab inline\r\nimport numpy as np\r\nimport scipy as sp\r\nfrom scipy import stats\r\nimport pylab as pb\r\nimport GPy\r\n```\r\n2. Training data\r\n```\r\n# Total number of sampling locations\r\nN = 25\r\n# sampling locations\r\nsampling_locations = np.array(np.linspace(0,1,N)) \r\n# Number of trials (fixed across sampling locations)\r\nns = np.array(np.repeat(100,N))\r\n# binomial responses  (i.e., # of successes in \"ns\" independent trials)\r\nbinomial_counts = np.array([96,89,89,75,82,71,67,53,51,45,34,28,17,17,6,4,1,2,5,1,1,0,1,0,0])\r\n```\r\n3. Model specification\r\n```\r\n# Matern covariance kernel\r\nkernel = GPy.kern.Matern52(1, variance=1, lengthscale=1)\r\n# Data likelihood\r\nlik = GPy.likelihoods.Binomial()\r\n# Inference method\r\nlaplace_inf = GPy.inference.latent_function_inference.Laplace()\r\n# Fit Binomial GP\r\nm = GPy.core.GP(\r\n    X = sampling_locations[:, None], \r\n    Y = binomial_counts[:, None],\r\n    kernel=kernel,\r\n    likelihood=lik,\r\n    Y_metadata={'trials': ns[:, None]},\r\n    inference_method=laplace_inf,\r\n)\r\n```\r\n4. Model fitting\r\n```\r\nm.optimize('bfgs', max_iters=100) \r\nm\r\n```\r\ngp. | value | constraints | priors\r\n-- | -- | -- | --\r\nMat52.variance | 16.960855285466533 | +ve |  \r\nMat52.lengthscale | 1.8283055551763174 | +ve |  \r\n\r\nI have two questions regarding the example above:\r\n\r\n1. **Can one specify the \"logit\" (canonical) link function instead of probit for Laplace approximation? It seems that the inference methods for Binomial data are only built upon the [probit link](https://github.com/SheffieldML/GPy/blob/devel/GPy/likelihoods/binomial.py#L26).**\r\n2. **How can I specify prior distributions for the hyper-parameters of the covariance kernel (process variance and length-scale in the table above)?**\r\n\r\nThank you very much and hope to hear soon from you:)"}}
{"actor":{"display_login":"checorh"}}