similar to: poly() with unnormalized values

Displaying 20 results from an estimated 3000 matches similar to: "poly() with unnormalized values"

2007 Jan 08
2
Contrasts for ordered factors
Dear all, I do not seem to grasp how contrasts are set for ordered factors. Perhaps someone can elighten me? When I work with ordered factors, I would often like to be able to reduce the used polynomial to a simpler one (where possible). Thus, I would like to explicetly code the polynomial but ideally, the intial model (thus, the full polynomial) would be identical to one with an ordered factor.
2005 Feb 23
1
model.matrix for a factor effect with no intercept
I was surprised by this (in R 2.0.1): > a <- ordered(-1:1) > a [1] -1 0 1 Levels: -1 < 0 < 1 > model.matrix(~ a) (Intercept) a.L a.Q 1 1 -7.071068e-01 0.4082483 2 1 -9.073800e-17 -0.8164966 3 1 7.071068e-01 0.4082483 attr(,"assign") [1] 0 1 1 attr(,"contrasts") attr(,"contrasts")$a [1]
2008 Mar 07
5
Puzzling coefficients for linear fitting to polynom
Hi, I can not comprehend the linear fitting results of polynoms. For example, given the following data (representing y = x^2): > x <- 1:3 > y <- c(1, 4, 9) performing a linear fit > f <- lm(y ~ poly(x, 2)) gives weird coefficients: > coefficients(f) (Intercept) poly(x, 2)1 poly(x, 2)2 4.6666667 5.6568542 0.8164966 However the fitted() result makes sense: >
2017 Jul 13
2
Quadratic function with interaction terms for the PLS fitting model?
Marc: 1. I am aware of the need to explicitly name arguments after ... -- see the R Language definition where this can be inferred from the argument matching rules. 2. I am aware of the stated exception for poly(). However: > x1 <- runif(20) > x2 <- runif(20) > mx <- cbind(x1,x2) > poly(mx,2) Error in poly(dots[[i]], degree, raw = raw, simple = raw) : 'degree'
2004 May 06
5
Orthogonal Polynomial Regression Parameter Estimation
Dear all, Can any one tell me how can i perform Orthogonal Polynomial Regression parameter estimation in R? -------------------------------------------- Here is an "Orthogonal Polynomial" Regression problem collected from Draper, Smith(1981), page 269. Note that only value of alpha0 (intercept term) and signs of each estimate match with the result obtained from coef(orth.fit). What
2007 Jan 25
1
poly(x) workaround when x has missing values
Often in practical situations a predictor has missing values, so that poly crashes. For instance: > x<-1:10 > y<- x - 3 * x^2 + rnorm(10)/3 > x[3]<-NA > lm( y ~ poly(x,2) ) Error in poly(x, 2) : missing values are not allowed in 'poly' > > lm( y ~ poly(x,2) , subset=!is.na(x)) # This does not help?!? Error in poly(x, 2) : missing values are not allowed in
2005 Nov 10
2
polynomials transformation
Dear All, Need some help in polynomials transformation to get the coefficients. I have tried "poly.transform" as applied in S-plus but it does not work. Thanks in advanced for any helps. Regards. Abd. Rahman Kassim (PhD) Head Forest Ecology Branch Forest Management & Ecology Program Forestry and Conservation Division Forest Research Institute Malaysia Kepong 52109 Selangor,
2010 Jan 18
2
Predict polynomial problem
I have a function that fits polynomial models for the orders in n: lmn <- function(d,n){ models=list() for(i in n){ models[[i]]=lm(y~poly(x,i),data=d) } return(models) } My data is: > d=data.frame(x=1:10,y=runif(10)) So first just do it for a cubic: > mmn = lmn(d,3) > predict(mmn[[3]]) 1 2 3 4 5 6 7 8
2017 Jul 13
0
Quadratic function with interaction terms for the PLS fitting model?
Bert, The 'degree' argument follows the "..." argument in the function declaration: poly(x, ..., degree = 1, coefs = NULL, raw = FALSE, simple = FALSE) Generally, any arguments after the "..." must be explicitly named, but as per the Details section of ?poly: "Although formally degree should be named (as it follows ...), an unnamed second argument of length 1
1999 May 05
1
Ordered factors , was: surrogate poisson models
For ordered factor the natural contrast coding would be to parametrize by the succsessive differences between levels, which does not assume equal spacing of factor levels as does the polynomial contrasts (implicitly at least). This requires the contr.cum, which could be: contr.cum <- function (n, contrasts = TRUE) { if (is.numeric(n) && length(n) == 1) levs <- 1:n
2017 Jul 13
0
Quadratic function with interaction terms for the PLS fitting model?
Hi Bert, Ok, to your initial point, the key nuance is that if 'x' is a vector, you can leave the 'degree' argument unnamed, however, if 'x' is a matrix, you cannot. That aspect of the behavior does not seem to change if poly() is called stand alone or, as suggested in ?poly, within a formula to be parsed. Working on tracing through the code using debug(), the error is
2011 Sep 20
3
adding labels to x,y points
Hi, I am new to R. I have a matrix that I have assigned to the object ?colon?. > colon<-read.table("c:\\alon.txt",header=T,row.names=1) attach(colon) names(colon) The dimenstions are 2000 62. Each of the 62 columns (titled norm1, norm2, norm3, etc) has 2000 different numbers (?continuous? values) within it. I have also assigned a name for each of the 2000 rows of the
2003 Oct 27
2
problem using do.call and substitute for predict.glm using poly()
Hi I am having a particular problem with some glm models I am running. I have been adapting code from Bill Venables 'Programmers niche' in RNews Vol 2/2 to fit ca. 1000 glm models to a combination of species 0/1 data (as Y) and related physicochemical data (X), to automate the process of fitting this many models. I have successfully managed to fit all the models and have stored the
1999 May 04
1
surrogate poisson models
Dear R-help, I'm applying the surrogate Poisson glm, by following Venables & Ripley (7.3 pp238-42). >overall_cbind(expand.grid(treatment=c("Pema","control"),age=c("young","adult","old"),repair=c("excellent","good","poor")),Fr=c(8,0,7,1,2,0,2,7,1,4,7,1, 0,3,2,5,1,9))
2008 Apr 22
1
Bug in poly() (PR#11243)
Full_Name: Russell Lenth Version: 2.6.2 OS: Windows XP Pro Submission from: (NULL) (128.255.132.36) The poly() function allows a higher-degree polynomial than it should, when raw=FALSE. For example, consider 5 distinct 'x' values, each repeated twice. we can fit a polynomial of degree 8: ===== R> x = rep(1:5, 2) R> y = rnorm(10) R> lm(y ~ poly(x, 8)) Call: lm(formula = y ~
2010 Jan 16
2
predict.glm
Hi, See below I reply your message for <https://stat.ethz.ch/pipermail/r-help/2008-April/160966.html>[R] predict.glm & newdata posted on Fri Apr 4 21:02:24 CEST 2008 You say it ##works fine but it does not: if you look at the length of yhat2, you will find 100 and not 200 as expected. In fact predict(reg1, data=x2) gives the same results as predict(reg1). So I am still looking for
2017 Jul 13
4
Quadratic function with interaction terms for the PLS fitting model?
poly(NIR, degree = 2) will work if NIR is a matrix, not a data.frame. The degree argument apparently *must* be explicitly named if NIR is not a numeric vector. AFAICS, this is unclear or unstated in ?poly. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom
2006 Mar 07
3
glm automation
Hello, I have two problems in automating multiple glm(s) operations. The data file is tab delimited file with headers and two columns. like "ABC" "EFG" 1 2 2 3 3 4 dat <- read.table("FILENAME", header=TRUE, sep="\t", na.strings="NA", dec=".", strip.white=TRUE) dataf <- read.table("FILENAME", header=FALSE,
2006 May 27
1
Recommended package nlme: bug in predict.lme when an independent variable is a polynomial (PR#8905)
Full_Name: Renaud Lancelot Version: Version 2.3.0 (2006-04-24) OS: MS Windows XP Pro SP2 Submission from: (NULL) (82.239.219.108) I think there is a bug in predict.lme, when a polynomial generated by poly() is used as an explanatory variable, and a new data.frame is used for predictions. I guess this is related to * not * using, for predictions, the coefs used in constructing the orthogonal
2004 Nov 24
1
reshaping of data for barplot2
Dear All, I have the following data coming out from s <- with(final, summarize(norm, llist(gtt,fdiab), function(norm) { n <- sum(!is.na(norm)) s <- sum(norm, na.rm=T) binconf(s, n) }, type='matrix') ) ie gtt fdiab norm.norm norm.norm2 norm.norm3 18