similar to: difference between ns and bs in predict.glm

Displaying 20 results from an estimated 1000 matches similar to: "difference between ns and bs in predict.glm"

2006 Oct 05
1
convert day of week from number to character and include in lm
All, I am trying to include a day of week variable (1-7) in in a regression model. I would like to have the day of week treated as a categorical variable rather than a number the code looks like lm( dep ~ WKDY) I know this is a basic question, but help would be appreciated thanks spencer [[alternative HTML version deleted]]
2006 Nov 09
0
interaction term between two categorical variables in ARIMA
hello, I am using arima to evaluate a time series regression model. I am using categorical variables such as day of week(Su-Sa), month(Jan-Dec), and holiday status (1/0) as my independent variables. There is evidence of multiplicative interaction between holiday status and weekday and I would like to add an interaction term to my arima model, but I am not sure about best way to go about doing it.
2006 Aug 31
0
periodic spline in glm
I have been trying to find a command similiar to bs or ns to add a periodic/or cyclical splie term to a regression model in glm.nb I have been using ns to fit a spline to day of the year (1:365): glm.nb(CNT ~ WKDY + ns(DY,df=6) + HOLIDAY_FLAG + Trend) but I think a periodic spline might be more appropriate. Any suggestions would be appreciated. best, Spencer Jones, M.Stat. NLM Fellow Dept.
2003 Jan 30
0
a question about spline A(ns or bs)
Hello: I have a question about spline: ns (or bs) in R (library: splines). What's the exact analytic form of the B splines generated by ns (or bs)? I need to calculate the penalty (square of second order derivative) of the basis functions. Is there any shortcut or I need to program myself? thanks, Shuangge Ma ********************* Department of Statistics Phone: 608-263-4782(O) University
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
2004 Oct 20
2
Odd behaviour with scale()
Moi! A student here has been getting a bit irritated with some side effects of scale() (OS is Windows XP, the behaviour occurs in R 2.0.0, but not 1.7.1). The problem is that she scales a variable in a data frame, then does a regression, and tries to get some predictions for some new data. However, at this point she gets an error (see the example below). This seems to be because the
2005 Jun 02
4
repeated vector in matrix
Hallo, I'll need a matrix with n rows of the an identical vector. > h [1] 3 3 3 3 2 2 2 The nmatrix should look like this: > x<-rbind(h,h,h) > x [,1] [,2] [,3] [,4] [,5] [,6] [,7] h 3 3 3 3 2 2 2 h 3 3 3 3 2 2 2 h 3 3 3 3 2 2 2 but I need n rows which must be variable. Can anyone help me? thanks Andreas
2010 Dec 04
2
Problem storing lm() model in a list
Hi all, I recently wrote some code to store a number of polynomial models in a list and return this list. The model is returned fine, but when I make a subsequent call to predict(), I have an error. The code for polyModel selection is listed at the end of the email. Here is an example of the error: > poly.fit <- polyModelSelection(x,y,10,F) > for (d in 1:4) { + lm.model <-
2008 Feb 26
1
predict.rpart question
Dear All, I have a question regarding predict.rpart. I use rpart to build classification and regression trees and I deal with data with relatively large number of input variables (predictors). For example, I build an rpart model like this rpartModel <- rpart(Y ~ X, method="class", minsplit =1, minbucket=nMinBucket,cp=nCp); and get predictors used in building the model like
2012 Mar 06
1
PLS Error message
Hi, I work with hyperspectral remote sensing data and I try to built a pls model with this data. I already built the model but if I try to calculate the RMSEP and R2 with a test data set I get the following error message: Error: variable 'subX' was fitted with type "nmatrix.501" but type "nmatrix.73" was supplied The problem is that I don't get the message for
2008 Apr 11
2
How to fill out some columns?
Dear R users, I'm working with 2 data sets which look like (for example) dx and dy in the next code: # Seed set.seed(4) # First data frame dx=matrix(rnorm(6*5),ncol=6) colnames(dx)=LETTERS[1:6] # Second data frame dy=matrix(rnorm(3*5),ncol=3) colnames(dy)=c('A','C','E') As you will notice, some columns in both data sets have the same names. At the end, what I need
2009 Aug 11
3
Lattice: How to do error bars
I am trying to add 2 stdev error bars to lattice type plots: panel.ebar<-function(x,y,dy=NULL,...) { panel.xyplot(x,y,...) panel.segments(x,y-dy,x,y+dy,...) } Then: xyplot(y~x|fc,data=dat,dy=dat$dy,panel=panel.ebar) This adds error bars but they are not conditioned on the factor fc. xyplot(y+I(y-dy)+I(y+dy)~x|fc,data=dat) This produces 3 series of points in different colors, conditioned
2012 Oct 10
3
Generating random geographical coordinates
Dear all, I have two coordinates vectors, say X and Y of length n. I want to generate for each couple of coordinates X1,Y1 X2,Y2 X3,Y3....Xn,Yn a random coordinate which is located in a square define as X +/- dx and Y +/- dy. I saw the runif function which can generate for just one value at a time what I want : runif(1, X - dx, X + dx) for X and runif(1, Y - dy, Y + dy) for Y. I would like
2002 Oct 06
6
error bars in line plots
Hi! Could you tell me how I can draw a graph with error bars? Sorry, I don't use R that often and I couldn't find it easily in the documentation. TIA -- myriam -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info",
2008 Aug 13
3
issue building dataframes with matrices.
Hello, Is this a bug or a feature? I am using R 2.7.1 on Apple OS X. > y <- matrix(1:3,nrow=3) # y is a single-column matrix > df <-data.frame(x=1:3,y=y) > sapply(df,data.class) x y "numeric" "numeric" > df$yy <- y > sapply(df,data.class) x y yy "numeric" "numeric" "matrix"
2011 Aug 11
1
Splitting data
I want to implement the following algorithm in R: I want to split my data, use a t test to compare both means of the groups to see if they significantly differ from each other. If this is a yes (p < alpha) I want to split again (into 4 groups) and do the same procedure twice, and stop otherwise (here the problem arises). As a final result I would have different groups of data. I made some
2011 Apr 19
1
How to Extract Information from SIMEX Output
Below is a SIMEX object that was generated with the "simex" function from the "simex" package applied to a logistic regression fit. From this mountain of information I would like to extract all of the values summarized in this line: .. ..$ variance.jackknife: num [1:5, 1:4] 1.684 1.144 0.85 0.624 0.519 ... Can someone suggest how to go about doing this? I can extract the
2002 Mar 21
1
legend - bug with argument angle (PR#1404)
When legend() is used with the angle argument as follows, not only the boxes beside the legend text, but also the whole legend box is filled with shading lines. I think this is not intended: plot(1:10) legend(8, 4, c("A", "B"), angle=c(10, 80), fill=NULL, density=20) I'd suggest as a fix (legend.R of R-1.5.0): 25c25 < rect2 <- function(left, top, dx, dy,
2012 Jul 29
1
Return od functions
Hi! I have some questions about R function. I try to write a function for multi-returns. The function code is as attachment. dgp.par<-function(ai, bi, t, n) { t0<-t+20 y0<-matrix(0, nr=t0, nc=n) y0[1,]<-ai/(1-bi) for(tt in 2:t0) { y0[tt,]<-ai+bi*y0[tt-1,]+rnorm(n, 0, 1) } y<-y0[21:t0,] x<-y0[20:t0-1,] z<-y0[19:t0-2,] z<-z[2:t,] dy<-y[2:t,]-y[1:t-1,]
2003 May 14
1
lme speedup question
I am hoping someone will be kind enough to have a look at the following piece of code and tell me if there is a way to run lme() so it is a lot faster. The inner loop, j in 1:15000, takes about 2 hrs on my 2.8GHz dual Xeon 4GB RAM machine. The timings I have done show the dominant execution time is in lme. options(contrasts=c("contr.sum", "contr.sum"))