[R] package installtion

Scott Raynaud scott.raynaud at yahoo.com
Wed Nov 16 20:41:45 CET 2011

```OK, I'm using William Browne's MLPowSim to create an R script which will simulate samples for estimation of sample size in mixed models.  I have subjects
nested in hospitals with hospitals treated as random and all of my covariates at level 1.  My outcome is death, so it's binary and I'll have a fixed and
random intercept.  My interest is in the relation of the covariates to the outcome.

My most important variable is gestational age (GA) which my investigators divide thusly: 23-24, 25-26, 27-28, 29-30 and 31-32.  I have recoded the
dummies for GA in the script according to the MLPowSim instructions to a random multinomial variable:

macpred<-rmultinom(n2,1,c(.1031,.1482,.2385,.4404,.0698))
x[,3]<-macpred[1,][l2id]
x[,4]<-macpred[2,][l2id]
x[,5]<-macpred[3,][l2id]
x[,6]<-macpred[4,][l2id]

GA 23-24 is the reference with p=.0698.  I started with a structured sampling scheme of 20, 60, 100, 120 and 140 level 2 units.  My level 2 units have
different sizes.  So at 20 I had 5 hospitals with 100 patients, 4 with 280, 3 with 460, 3 with 640, 3 with 820 and 2 with 1000.  Thus, at 60 hospitals, I have 15,
12, 9, 9, 9, 6 with the same cell sample sizes.

According to the MLPowSim documentation, with small probablities it's possible to have a column of zeroes in the X matrix if there are not many units in
the random factor.  R will choke on this but MLWin sets the associated fixed effects to 0.  When R choked, I increased from 20 to 60 as my minimum as
suggested in the MLPowSim documentation.  Still no luck.

----- Original Message -----
From: Uwe Ligges <ligges at statistik.tu-dortmund.de>
To: r-help at r-project.org
Cc: Scott Raynaud <scott.raynaud at yahoo.com>
Sent: Wednesday, November 16, 2011 1:01 PM
Subject: Re: [R] package installtion

On 16.11.2011 17:37, Scott Raynaud wrote:
> That might be an option if it weren't my most important predictor.  I'm thinking my best bet is to use MLWin for the estimation since it will properly set fixed effects
>  to 0.  All my other sample size simulation programs use SAS PROC IML which I don't have/can't afford.  I like R since it's free, but I can't work around the problem
> I'm currently having.

Then you really have to describe your problem much better: If you most
important predictor is really all zero, then you have a real problem .....

Uwe Ligges

>
>
> ----- Original Message -----
> From: Uwe Ligges<ligges at statistik.tu-dortmund.de>
> To: Scott Raynaud<scott.raynaud at yahoo.com>
> Cc: "r-help at r-project.org"<r-help at r-project.org>
> Sent: Wednesday, November 16, 2011 9:48 AM
> Subject: Re: [R] package installtion
>
>
>
> On 16.11.2011 16:08, Scott Raynaud wrote:
>> All right.  I upped my level 2 sample size to 60.  My log displays the following:
>>
>>                    Simulation for sample sizes of  60  macro and unbalanced micro units
>>    Iteration remain= 990
>>    Iteration remain= 980
>> There were 27 warnings (use warnings() to see them)
>> Error in diag(vcov(fitmodel)) :
>>      error in evaluating the argument 'x' in selecting a method for function 'diag': Error in asMethod(object) : matrix is not symmetric [1,2]
>>
>> Looking at the warnings I see:
>>
>> 26: glm.fit: algorithm did not converge
>> 27: In mer_finalize(ans) : gr cannot be computed at initial par (65)
>>
>> The first 25 are like 26.  So, it seems I'm having the same problem as before.  Again, if this is due to a column of zeroes in my x matrix, the best solution would be to assign zeroes to the fixed effects, but I'm not sure if there's a way to do this.
>
> Why don't you simply delete that variable and hence don't estimate
> coefficients for it....
>
> Uwe Ligges
>
>
>
>
>>
>> ----- Forwarded Message -----
>> From: Scott Raynaud<scott.raynaud at yahoo.com>
>> To: "r-help at r-project.org"<r-help at r-project.org>
>> Cc:
>> Sent: Wednesday, November 16, 2011 7:28 AM
>> Subject: Re: [R] package installtion
>>
>> Well, I could increase the sample size for my second level in hopes that my simulation would run correctly.  However, a better solution would be to assign values of 0 to the fixed effects for this pass through the simulation.  I'm such a novice with R that I don't know if that can be done.  I've looked at the documentation but it's still not clear.
>>
>>
>> ----- Original Message -----
>> From: Uwe Ligges<ligges at statistik.tu-dortmund.de>
>> To: Scott Raynaud<scott.raynaud at yahoo.com>
>> Cc: "r-help at r-project.org"<r-help at r-project.org>
>> Sent: Wednesday, November 16, 2011 2:44 AM
>> Subject: Re: [R] package installtion
>>
>>
>>
>> On 15.11.2011 21:34, Scott Raynaud wrote:
>>> OK, I think I see the problem.  Rather than setting method="nAGQ" I need nAGQ=1.  Doing so throws the following error:
>>
>> Congratulations, now you understood what R meant with its message
>> "Argument ‘method’ is deprecated."
>>
>>> "Warning messages:
>>> 1: glm.fit: algorithm did not converge
>>> 2: In mer_finalize(ans) : gr cannot be computed at initial par (65)
>>> Error in diag(vcov(fitmodel)) :
>>>        error in evaluating the argument 'x' in selecting a method for function 'diag': Error in asMethod(object) : matrix is not symmetric [1,2]"
>>>
>>> I need some help interpreting and debugging this.  One thing that I suspect is that there is a column of zeroes in the design matrix,
>>
>> So have you not even tried to get rid of that? Oh, come on.
>>
>> Uwe Ligges
>>
>>
>>
>>> but I'm not sure.  Any other possibilities here and how can I diagnose?
>>>
>>> ----- Original Message -----
>>> From: Scott Raynaud<scott.raynaud at yahoo.com>
>>> To: "r-help at r-project.org"<r-help at r-project.org>
>>> Cc:
>>> Sent: Tuesday, November 15, 2011 2:11 PM
>>> Subject: Re: package installtion
>>>
>>> Never mind-I fixed it.
>>>
>>> My script is throwing the following error:
>>>
>>> "Error in glmer(formula = modelformula, data = data, family = binomial(link = logit),  :
>>>        Argument ‘method’ is deprecated.
>>> Use ‘nAGQ’ to choose AGQ.  PQL is not available."
>>>
>>> I remember hearing somewhere that PQL is no longer available on lme4 but I have AGQ specified.
>>>
>>> Here's the line that fits my model:
>>>
>>>
>>> If I change it to nAGQ I still get an error.
>>>
>>> Any ideas as to what's going on?
>>>
>>> ----- Original Message -----
>>> From: Scott Raynaud<scott.raynaud at yahoo.com>
>>> To: "r-help at r-project.org"<r-help at r-project.org>
>>> Cc:
>>> Sent: Tuesday, November 15, 2011 1:50 PM
>>> Subject: package installtion
>>>
>>> I'm getting the following error in a script: "Error: could not find function "lmer."    I'm wondering of my lme4 package is installed incorrectly.  Can someone tell me the installation procedure?  I looked at the support docs but couldn't translate that into anything that would work.
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> and provide commented, minimal, self-contained, reproducible code.
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help