Displaying 20 results from an estimated 5000 matches similar to: "model.matrix() may be misleading for "lme" models"
2024 Sep 21
1
model.matrix() may be misleading for "lme" models
Dear list members,
After further testing, I found that the following simplified version of
model.matrix.lme(), which omits passing xlev to the default method, is
more robust. The previous version generated spurious warnings in some
circumstances.
model.matrix.lme <- function(object, ...){
data <- object$data
if (is.null(data)){
NextMethod(formula(object),
2024 Sep 22
1
model.matrix() may be misleading for "lme" models
Dear Ivan,
Thank you for addressing my questions with your usual thoroughness.
Please see below:
On 2024-09-21 2:51 p.m., Ivan Krylov wrote:
> [You don't often get email from ikrylov at disroot.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Caution: External email.
>
>
> Dear Prof. John Fox,
>
> ? Sat, 21 Sep 2024 12:47:49
2024 Sep 21
1
model.matrix() may be misleading for "lme" models
Dear Prof. John Fox,
? Sat, 21 Sep 2024 12:47:49 -0400
John Fox <jfox at mcmaster.ca> ?????:
> NextMethod(formula(object), data=eval(object$call$data),
> contrasts.arg=object$contrasts)
The use of NextMethod worries me a bit. It will work as intended as
long as everyone gives fully-named arguments to the generic, without
relying on positional or partial
2024 Sep 23
1
model.matrix() may be misleading for "lme" models
? Sun, 22 Sep 2024 10:23:50 -0400
John Fox <jfox at mcmaster.ca> ?????:
> > Evaluating object$call$data in the environment of the suggested
> > nlme:::model.matrix.lme function may also not work right. Without an
> > explicit copy of the data, the best environment to evaluate it in
> > would be parent.frame().
>
> I'm afraid that I don't understand
2006 Apr 19
1
Can't run code from "Mixed Effects Models in S and S-plus"
Dear R-users:
I can't run the following code from "Mixed Effects Models in S and S-plus".
library( nlme )
options( width = 65, digits = 5 )
options( contrasts = c(unordered = "contr.helmert", ordered = "contr.poly")
)
# Chapter 5 Extending the Basic Linear Mixed-Effects Models
# 5.1 General Formulation of the Extended Model
data( Orthodont )
vf1Fixed
2002 Oct 24
3
model.matrix (via predict) (PR#2206)
Full_Name: Glenn Stone
Version: 1.5.1 and 1.6.0
OS: win2000
Submission from: (NULL) (168.140.227.9)
The following code produces incorrect fitted values in version 1.5.1 and an
error in 1.6.0
Error in "contrasts<-"(*tmp*, value = "contr.treatment") :
contrasts apply only to factors
In addition: Warning message:
variable ihalf is not a factor in:
2024 Sep 23
1
model.matrix() may be misleading for "lme" models
> I can't tell whether evaluating object$call$data in
environment(object$formula) is a better or worse idea than parent.frame().
I have struggled with this a lot over the years. There is a bunch of
wonky code in lme4, e.g. here
<https://github.com/lme4/lme4/blob/master/R/lmer.R#L814-L838>, that
tries to look for data in different possible locations, but I don't
think anything
2011 May 18
1
Need expert help with model.matrix
Dear experts:
Is it possible to create a new function based
on stats:::model.matrix.default so that an alternative factor coding is used
when the function is called instead of the default factor coding?
Basically, I'd like to reproduce the results in 'mat' below, without having
to explicitly specify my desired factor coding (identity matrices) in the
'contrasts.arg'.
dd
2003 Mar 26
2
predict (PR#2685)
There is a bug in `predict' whereby the order of variables sometimes gets
re-arranged compared to the original fit, and then disaster results.
Specifically, the 'variables' and 'predvars' attributes of a 'terms' object
get out of synch. This only happens when the terms in the original formula
get re-ordered during fitting:
test> scrunge.data_ data.frame(
2009 Feb 26
1
using predict method with an offset
Hi,
I have run into another problem using offsets, this time with
the predict function, where there seems to be a contradiction
again between the behavior and the help page.
On the man page for predict.lm, it says
Offsets specified by offset in the fit by lm will not be included in
predictions, whereas those specified by an offset term in the formula
will be.
While it indicates nothings about
2004 Jan 30
0
Two apparent bugs in aov(y~ *** -1 + Error(***)), with suggested (PR#6510)
I think there are two bugs in aov() that shows up when the right hand
side of `formula' contains both `-1' and an Error() term, e.g.,
aov(y ~ a + b - 1 + Error(c), ...). Without `-1' or `Error()' there
is no problem. I've included and example, and the source of aov()
with suggested fixes below.
The first bug (labeled BUG 1 below) creates an extra, empty stratum
inside
2004 Feb 02
0
Two apparent bugs in aov(y~ *** -1 + Error(***)), with (PR#6520)
I believe you are right, but can you please explain why anyone would want
to fit this model? It differs only in the coding from
aov(y ~ a + b + Error(c), data=test.df)
and merely lumps together the top two strata.
There is a much simpler fix: in the line
if(intercept) nmstrata <- c("(Intercept)", nmstrata)
remove the condition (and drop the empty stratum later if you
2005 Aug 15
1
error in predict glm (new levels cause problems)
Dear R-helpers,
I try to perform glm's with negative binomial distributed data.
So I use the MASS library and the commands:
model_1 = glm.nb(response ~ y1 + y2 + ...+ yi, data = data.frame)
and
predict(model_1, newdata = data.frame)
So far, I think everything should be ok.
But when I want to perform a glm with a subset of the data,
I run into an error message as soon as I want to predict
2011 Nov 10
3
Creating dummys in R
Dear R-project!
How do i create 1 dummy from 2 already existing dummys. To be more precise, I want to create a dummy from a dummy called "sex" and another called "sex1" when both thoose dummys are 1 I want my created dummy "samesex" to take 1.
Thanks for the help!
Paulie
[[alternative HTML version deleted]]
2013 Apr 12
2
model frame and formula mismatch in model.matrix()
Hello everyone,
I am trying to fit the following model
All X. variables are continuous, while the conditions are categoricals.
model <- lm(X2
2012 Jan 03
1
returning information from functions via attributes rather than return list
I would like to ask for advice from R experts about the benefits or
dangers of using attr to return information with an object that is
returned from a function. I have a feeling as though I have cheated by
using attributes, and wonder if I've done something fishy.
Maybe I mean to ask, where is the dividing line between attributes and
instance variables? The separation is not clear in my mind
2013 Apr 05
2
model.frame: object is not a matrix
Over a decade ago there was a problem with model.frame when the variable
names were long:
https://stat.ethz.ch/pipermail/r-help/2002-August/024492.html
I have similar symptoms with R 2.15.3 on Windows 7:
Browse[2]> x <- model.matrix(formula(myform), p$data)
Error in model.frame.default(object, data, xlev = xlev) (from mice.R#601) :
object is not a matrix
My attempt at a work-around
2008 Jul 18
2
column wise paste of data.frames
Hi everybody!
I'm sure that I overlook something and feel quite stupid to ask, but I
have not found an easy solution to the following problem: Take e.g. the
Orthodont data from the nlme package:
> head(Orthodont)
Grouped Data: distance ~ age | Subject
distance age Subject Sex
1 26.0 8 M01 Male
2 25.0 10 M01 Male
3 29.0 12 M01 Male
4 31.0 14 M01 Male
2010 Jun 22
2
xyplot: adding pooled regression lines to a paneled type="r" plot
Consider the following plot that shows separate regression lines ~ age
for each subject in the Pothoff-Roy Orthodont data,
with separate panels by Sex:
library(nlme)
#plot(Orthodont)
xyplot(distance ~ age|Sex, data=Orthodont, type='r', groups=Subject,
col=gray(.50),
main="Individual linear regressions ~ age")
I'd like to also show in each panel the pooled OLS
2019 Aug 30
3
inconsistent handling of factor, character, and logical predictors in lm()
Dear R-devel list members,
I've discovered an inconsistency in how lm() and similar functions handle logical predictors as opposed to factor or character predictors. An "lm" object for a model that includes factor or character predictors includes the levels of a factor or unique values of a character predictor in the $xlevels component of the object, but not the FALSE/TRUE values