1

In R, I would like to test the specification of a partial least square (PLS) model m1 against a non-nested alternative m2, applying the Davidson-MacKinnon J test. For a simple linear outcome Y it works quite well using the plsr estimator followed by the jtest command:

# Libraries and data
library(plsr)
library(plsRglm)  
library(lmtest)
Z <- Cornell # illustration dataset coming with the plsrglm package

# Simple linear model
m1 <- plsr(Z$Y ~ Z$X1 + Z$X2 + Z$X3 + Z$X4 + Z$X5 ,2) # including X1
m2 <- plsr(Z$Y ~ Z$X6 + Z$X2 + Z$X3 + Z$X4 + Z$X5 ,2) # including X6 as alternative
jtest(m1,m2)

However, if Iuse the generalized linear model (plsRglm) estimator to account for a possible nonlinear distibution of an outcome, e.g.:

# Generalized Model
m1 <- plsRglm(Z$Y ~ Z$X1 + Z$X2 + Z$X3 + Z$X4 + Z$X5 ,2, modele = "pls-glm-family", family=Gamma(link = "log"), pvals.expli=TRUE)
m2 <- plsRglm(Z$Y ~ Z$X6 + Z$X2 + Z$X3 + Z$X4 + Z$X5 ,2, modele = "pls-glm-family", family=Gamma(link = "log"), pvals.expli=TRUE)    

I am running into an error when using jtest:

> jtest(m1,m2)
Error in terms.default(formula1) : no terms component nor attribute
> 

It seems that plsRglm does not save objects of class "formula", that jtest can handle. Has anybody a suggestion of how to edit my code to get this to work?

Thanks!

Lexx
  • 23
  • 2
  • Does specifying the formula correctly (i.e. omitting `Z$` and specifying `data` argument) help? – Roman Luštrik Jun 09 '17 at 12:55
  • No, it doesn't. It gets me the error : `Error in eval(expr, envir, enclos) : object 'Y' not found`. As can be expected, binding the X variables into a matrix (default S3 method) doesn't help either. Then I get: `Error in formula.default(object, env = baseenv()) : invalid formula` – Lexx Jun 09 '17 at 16:51
  • Even if `jtest` seems to work with `plsr` objects, it cannot be used to test the specification of PLS. Looking inside the code of `jtest` you can see that it estimates 2 linear models using `lm`, independently of the class of input models. – Marco Sandri Jun 15 '17 at 09:55

0 Answers0