[R] Simulating points from GLM corresponding to new x-values
Jacob Nabe-Nielsen
jacobnabe at me.com
Wed Aug 12 21:51:31 CEST 2009
Hi Cliff -- thanks for the suggestion.
I tried extracting the predicted mean and standard error using
predict(). Afterwards I simulated the dependent variable using
rnorm(), with mean and standard deviation taken from the predict()
function (sd = sqrt(n)*se). The points obtained this way were
scattered far too much (compared to points obtained with simulate())
-- I am not quite sure why.
Unfortunately the documentation of the simulate() function does not
provide much information about how it is implemented, which makes it
difficult to judge which method is best (predict() or simulate(), and
it is also unclear whether simulate() can be applied to glms (with
family=gaussian or binomial).
Any suggestions for how to proceed?
Jacob
On 12 Aug 2009, at 13:11, Clifford Long wrote:
> Would the "predict" routine (using 'newdata') do what you need?
>
> Cliff Long
> Hollister Incorporated
>
>
>
> On Wed, Aug 12, 2009 at 4:33 AM, Jacob Nabe-
> Nielsen<jacobnabe at me.com> wrote:
>> Dear List,
>>
>> Does anyone know how to simulate data from a GLM object correponding
>> to values of the independent (x) variable that do not occur in the
>> original dataset?
>>
>> I have tried using simulate(), but it generates a new value of the
>> dependent variable corresponding to each of the original x-values,
>> which is not what I need. Ideally I whould like to simulate new
>> values
>> for GLM objects both with family="gaussian" and with
>> family="binomial".
>>
>> Thanks in advance,
>> Jacob
>>
>> Jacob Nabe-Nielsen, PhD, MSc
>> Scientist
>> --------------------------------------------------
>> Section for Climate Effects and System Modelling
>> Department of Arctic Environment
>> National Enviornmental Research Institute
>> Aarhus University
>> Frederiksborgvej 399, Postbox 358
>> 4000 Roskilde, Denmark
>>
>> email: nabe at dmu.dk
>> fax: +45 4630 1914
>> phone: +45 4630 1944
>>
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
More information about the R-help
mailing list