Sampling from a GLM

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Sampling from a GLM

Roger Herikstad
Hi, 
Is there an established way of sampling from a fitted GLM? I can manually extract the parameters from the model and then use ``rand`` with the appropriate Distribution type, but I was hoping for a function that could do all that automatically, something like

 function sample(Q::DataFrameRegressionModel, args...)


--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Sampling from a GLM

John Myles White
I don’t think there’s anything like this at the moment.

 — John

On Jul 30, 2014, at 8:12 PM, Roger Herikstad <[hidden email]> wrote:

Hi, 
Is there an established way of sampling from a fitted GLM? I can manually extract the parameters from the model and then use ``rand`` with the appropriate Distribution type, but I was hoping for a function that could do all that automatically, something like

 function sample(Q::DataFrameRegressionModel, args...)



--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Sampling from a GLM

Roger Herikstad
Thanks for the clarification, I'll put something together for that. On a related note, is there an easy way to get the mapping from a categorical variable to its representation in a PooledDataArray? In my model, I have a mix of a continuous (b) and a categorical variable (stim):

julia> Q
DataFrameRegressionModel{GeneralizedLinearModel,Float64}:

Coefficients:
               Estimate  Std.Error   z value Pr(>|z|)
(Intercept)     1.48507  0.0694482   21.3838   <1e-99
b             0.0653932 0.00716286   9.12948   <1e-19
stim - 3      -0.336226  0.0993492  -3.38428   0.0007
stim - 4      -0.302432   0.102944  -2.93784   0.0033
stim - 5       0.119446  0.0908154   1.31526   0.1884
stim - 6      0.0714762  0.0913704  0.782268   0.4341
stim - 7      -0.314954   0.105878   -2.9747   0.0029
stim - 8      0.0843912  0.0912605  0.924728   0.3551
stim - 9     -0.0990329     0.1267 -0.781636   0.4344

Now, to sample from this model, I need to construct a matrix M of the independent variables and then do:

M*coefs(Q)

My actual category labels range from 1-9, so to construct the matrix M, I would need to convert these labels to the proper sequence of 1's and 0's. I was looking through the code for DataFrames/DataArrays, but I couldn't quite figure out how the mapping is constructed. Any help would be appreciated.
 
On Thursday, July 31, 2014 1:42:16 PM UTC+8, John Myles White wrote:
I don’t think there’s anything like this at the moment.

 — John

On Jul 30, 2014, at 8:12 PM, Roger Herikstad <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="WCet7tezRLoJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">roger.h...@...> wrote:

Hi, 
Is there an established way of sampling from a fitted GLM? I can manually extract the parameters from the model and then use ``rand`` with the appropriate Distribution type, but I was hoping for a function that could do all that automatically, something like

 function sample(Q::DataFrameRegressionModel, args...)



--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="WCet7tezRLoJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">julia-stats...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.