Error: invalid link function specified: NA

Welcome to the forum for R2MLwiN users. Feel free to post your question about R2MLwiN here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to R2MLwiN: Running MLwiN from within R >> http://www.bris.ac.uk/cmm/software/r2mlwin/
Post Reply
manolo01
Posts: 2
Joined: Sat Oct 06, 2018 2:01 pm

Error: invalid link function specified: NA

Post by manolo01 » Sat Oct 06, 2018 2:17 pm

Hi,
this is the first time I am using R2MLwiN.

I want to run a model with random effects only. My database is a sub-sample of the Multiple Indicator Cluster Survey developed by UNICEF. By response variable is a binary variable where 1 indicates age of marriage before 18 y.o. and 0 indicates age of marriage after 18 y.o.

This is the code I wrote

Code: Select all

F1 <- logit(agem.18) ~ 1 + (1 | province) + (1 | w.id)
rand.eff <- runMLwiN(Formula = F1, D = "Binomial", data = moz.20)
and I get the following error message

Code: Select all

Invalid link function specified: NA 
Error in runMLwiN(Formula = F1, D = "Binomial", data = moz.20)
I am not sure what is causing this error. The response variable is a binary

Code: Select all

> str(moz.20$agem.18)
 Factor w/ 2 levels "No","Yes": 2 1 1 1 2 1 1 2 2 2 ...
Does it have anything to do with the denom? I read that when it is not specified, the denom is automatically set to 1.

Thanks for your help

Manolo

ChrisCharlton
Posts: 1071
Joined: Mon Oct 19, 2009 10:34 am

Re: Error: invalid link function specified: NA

Post by ChrisCharlton » Mon Oct 08, 2018 9:21 am

This appears to be a bug in our code for parsing the model formula where it does not correctly handle a "." in the response name, for example:

Code: Select all

> library(R2MLwiN)
> data(bang, package = "R2MLwiN")
> (mymodel1 <- runMLwiN(logit(use) ~ 1 + lc, D = "Binomial", data = bang))

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- 
MLwiN (version: 3.02)  multilevel model (Binomial) 
Estimation algorithm:  IGLS MQL1        Elapsed time : 0.6s 
Number of obs:  2867 (from total 2867)        The model converged after 4 iterations.
Log likelihood:      NA 
Deviance statistic:  NA 
--------------------------------------------------------------------------------------------------- 
The model formula:
logit(use) ~ 1 + lc
Level 1: l1id      
--------------------------------------------------------------------------------------------------- 
The fixed part estimates:  
                    Coef.   Std. Err.        z    Pr(>|z|)         [95% Conf.   Interval] 
Intercept        -1.12288     0.08348   -13.45    3.05e-41   ***     -1.28650    -0.95926 
lcOne_child       0.93275     0.12156     7.67   1.676e-14   ***      0.69450     1.17100 
lcTwo_children    1.09250     0.12509     8.73   2.466e-18   ***      0.84733     1.33768 
lcThree_plus      0.87224     0.10302     8.47   2.523e-17   ***      0.67033     1.07416 
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1  
--------------------------------------------------------------------------------------------------- 
The random part estimates at the l1id level: 
                Coef.   Std. Err. 
var_bcons_1   1.00000     0.00000 
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- 

> bang$use.test <- bang$use
> (mymodel1 <- runMLwiN(logit(use.test) ~ 1 + lc, D = "Binomial", data = bang))
Invalid link function specified: NA 
Error in runMLwiN(logit(use.test) ~ 1 + lc, D = "Binomial", data = bang) : 
Until this is fixed the workaround would be to rename agem.18 to remove the "." character.

manolo01
Posts: 2
Joined: Sat Oct 06, 2018 2:01 pm

Re: Error: invalid link function specified: NA

Post by manolo01 » Mon Oct 08, 2018 10:44 am

Thank you, Chris,
I renamed the variable as suggested and now it works and I was able to fit my models.
I posted the same question on StackOverFlow, can I share the link to this page as credit for your reply and close the question there?
Cheers
Manolo

ChrisCharlton
Posts: 1071
Joined: Mon Oct 19, 2009 10:34 am

Re: Error: invalid link function specified: NA

Post by ChrisCharlton » Mon Oct 08, 2018 1:29 pm

I am glad to hear that this is now working for you. Yes, you are welcome to link to this page if you wish. I have now also added a reference to this bug to the R2MLwiN known bugs page (http://www.bristol.ac.uk/cmm/software/r ... nbugs.html).

Post Reply