Displaying 20 results from an estimated 900 matches similar to: "Subclassing lm"
2006 Jan 03
1
Extending a data frame with S4
I'm trying to create an extension to data.frame with more complex row
and column names, and have run into some problems:
> setClass("new-data.frame", representation("data.frame"))
[1] "new-data.frame"
Warning message:
old-style ('S3') class "data.frame" supplied as a superclass of
"new-data.frame", but no automatic conversion will
2020 Sep 24
2
Is it possible to simply the use of NULL slots (or at least improve the help files)?
Hi Martin,
Thankyou for your response.
I suspect that we're not going to agree on the main point.
Making it trivially simple (as say Java) to set slots to NULL.
So, I'll move on to the other points here.
***Note that cited text uses excerpts only.***
> setClassUnion("character_OR_NULL", c("character", "NULL"))
> A = setClass("A", slots =
2004 Mar 08
2
getting the std errors in the lm function
Hello,
I have a simple question for you:
making:
mylm<-lm(y~x)
summary(mylm)
I get the following results:
******************************************************
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 16.54087 0.19952 82.91 <2e-16 ***
x[1:19] -2.32337 0.04251 -54.66 <2e-16 ***
******************************************************
2010 Sep 14
1
NA confusion (length question)
Hi folks,
I am running a very simple regression using
mylm <- lm(mass ~ tarsus, na.action=na.exclude)
I would like the use the residuals from this analysis for more
regression but I'm running into a snag when I try
cbind(mylm$residuals, mydata) # where my data is the original data set
The error tells me that it cannot use cbind because the length of
mylm$residuals is
2005 Apr 20
2
Suggestions for manipulating formula objects
I'm trying to manipulate/change a formula prior to passing it to another
function. A simplified example:
User passes formula to my function: y~x
My function does: lm(transform(y)~x)
Here, transform() is added to the model's response.
What is the best way to accomplish this?
2009 Mar 31
1
using "substitute" inside a legend
Hello list,
I have a linear regression:
mylm = lm(y~x-1)
I've been reading old mail postings as well as the plotmath demo and I came
up with a way to print an equation resulting from a linear regression:
model = substitute(list("y"==slope%*%"x", R^2==rsq),
list(slope=round(mylm$coefficients[[1]],2),rsq=round(summary(mylm)$adj.r.squared,
2)))
I have four models and I
2009 May 14
1
automated polynomial regression
Dear all -
We perform some measurements with a machine that needs to be
recalibrated. The best calibration we get with polynomial regression.
The data might look like follows:
> true_y <- c(1:50)*.8
> # the real values
> m_y <- c((1:21)*1.1, 21.1, 22.2, 23.3 ,c(25:50)*.9)/0.3-5.2
> # the measured data
> x <- c(1:50)
> # and the x-axes
>
> # Now I do the following:
2011 May 20
2
extraction of mean square value from ANOVA
Hello,
I am randomly generating values and then using an ANOVA table to find the
mean square value. I would like to form a loop that extracts the mean square
value from ANOVA in each iteration. Below is an example of what I am doing.
a<-rnorm(10)
b<-factor(c(1,1,2,2,3,3,4,4,5,5))
c<-factor(c(1,2,1,2,1,2,1,2,1,2))
mylm<-lm(a~b+c)
anova(mylm)
Since I would like to use a loop to
2009 Jan 24
2
how to prevent duplications of data within a loop
Hi All,
I had posted a question on a similar topic, but I think it was not
focused. I am posting a modification that I think better accomplishes
this.
I hope this is ok, and I apologize if it is not. :)
I am looping through variables and running several regressions. I have
reason to believe that the data is being duplicated because I have
been
monitoring the memory use on unix.
How can I avoid
2007 Apr 06
2
lm() intercept at the end, rather than at the beginning
Hi,
I wonder if someone has already figured out a way of making
summary(mylm) # where mylm is an object of the class lm()
to print the "(Intercept)" at the last line, rather than the first
line of the output. I don't know about, say, biostatistics, but in
economics the intercept is usually the least interesting of the
parameters of a regression model. That's why, say, Stata
2005 Jun 16
1
regressing each column of a matrix on all other columns
DeaR list
I would like to predict the values of each column of a matrix A by
regressing it on all other columns of the same matrix A. I do this with
a for loop:
A <- B <- matrix(round(runif(10*3,1,10),0),10)
A
for (i in 1:length(A[1,])) B[,i] <- as.matrix(predict(lm( A[,i] ~
A[,-i] )))
B
It works fine, but I need it to be faster. I've looked at *apply but
just can't
2007 Oct 30
1
Some matrix and sandwich questions
Dear R-help,
I have a four-part question about regression, matrices, and sandwich package.
1) In the sandwich package, I would like to better understand the
meat() function.
>From the bread() documentation, for a simple OLS regression, bread() returns
(1/n * X'X)^(-1)
That is, for a simple regression (per the documentation on bread()):
MyLM <- lm(y ~ x)
bread(MyLM)
2020 Sep 24
0
Is it possible to simply the use of NULL slots (or at least improve the help files)?
Answering to convey the 'rules' as I know them, rather than to address the underlying issues that I guess you are really after...
The S4 practice is to use setOldClass() to explicitly treat an S3 character() vector of classes as an assertion of linear inheritance
> x <- structure (sqrt (37), class = c ("sqrt.prime", "numeric") )
> is(x,
2004 Sep 30
1
Problem with _new_ if class "lm" in object representatio n.
Hi,
But "any" rises some other problems well known from S3. One has "any"
for "free" in S3. You don't need S4. . But I know how "if" polluted
functions look like in S3. They are hard to understand and to
maintain. Hence I am quite happy to use S4.
Type-checking is usefull if you program with data. Also if you are on
the "C side" of the
2004 Jul 22
2
Files and classes in a package?
While installing my small package, I met a tricky problem.
For clarity, let me explain it with the following simplified example.
In ~/pkg/R/aclass.R,
setClass("aclass", contains="bclass", representation(i="numeric"))
In ~/pkg/R/bclass.R,
setClass("bclass", representation(j="numeric"))
After building a "pkg" package, the file
2005 Jun 19
1
1-based arrays and copying vectors
I'm interfacing to C code that uses 1-based indexing on arrays -- it
ignores the zeroth element. Thus, input vectors from R must be moved up
one, and output arrays must be moved down one.
What is the best way to deal with this using R internal code?
My current approach is:
For an input R vector of length n, allocate a new vector(v) of length n+1
and copy input into v[1] to v[1+n]. Call
2002 Jul 01
1
a little statistics help
Dear R-guRus:
I am stuck with the following problem in R:
Let's say i have a data.frame with columns X,Y & Z.
X is a column of numbers, Y is a column of N
factors "A", "B", "C", "D", etc and Z is a column of n
factors "a", "b", "c", etc
if i do MyLm<-lm(X~Y*Z - 1) i get all N coefficients for Y-factors, but
only
2002 Oct 03
2
lm fitting with a specified slope
Is there an easy way to do a linear model with an a priori known slope?
In essence, I want to minimize the residuals around a line of known slope.
-R
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the
2004 Jul 30
1
Three-way ANOVA?
Hi,
I'm a biologist, so please forgive me if my question sounds absurd! I have 3
parameters x1, x2, x3 and a response variable y.The sample size is 75. I tried
to do the following:
mylm<-lm(y~ x1 + x2 + x3, data="mydata")
but i can only get stats from anova for the first 2 variables. The third comes
up as NA. The degrees of freedom for the third variable are 0.
Is there
2006 Jan 16
4
Standardized beta-coefficients in regression
Hello list,
I am used to give a lot of attention to the standardized regression
coefficients, which in SPSS are listed automatically.
Is there alternative to running the last two lines in the following example to
get all the information?
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
summary( lm(ctl ~ trt) )