similar to: Specifying formula inside a function

Displaying 20 results from an estimated 10000 matches similar to: "Specifying formula inside a function"

2010 Apr 08
2
Overfitting/Calibration plots (Statistics question)
This isn't a question about R, but I'm hoping someone will be willing to help. I've been looking at calibration plots in multiple regression (plotting observed response Y on the vertical axis versus predicted response [Y hat] on the horizontal axis). According to Frank Harrell's "Regression Modeling Strategies" book (pp. 61-63), when making such a plot on new data
2013 Apr 23
2
Frustration to get help R users group
Dear R users/developers I requested help to solve the problem of formulating Multivariate Sample selection model by using Full Information Maximum Likelihood (FIML)estimation method. I could not get any response. I formulated the following code of FIML to analyse univariate sample selection problem. Would you please advise me where is my problem library (sem) library(nrmlepln) Selection
2009 Oct 13
2
update.formula drop interaction terms
Dear R users, How do I drop multiplication terms from a formula using update? e.g. forml=as.formula("Surv(time, status) ~ x1+x2+A*x3+A*x4+B*x5+strata(sex)") #I would like to drop all instances of variable A (the main effect and its interactions). The following: updated.forml=update(forml, ~ . -A) #gives me this: #Surv(time, status) ~ x1 + x2 + x3 + x4 + B + x5 + strata(sex) + A:x3 +
2017 Aug 22
1
boot.stepAIC fails with computed formula
SImplify your call to lm using the "." argument instead of manipulating formulas. > strt <- lm(y1 ~ ., data = dat) and you do not need to explicitly specify the "1+" on the rhs for lm, so > frm2<-as.formula(paste(trg," ~ ", paste(xvars,collapse = "+"))) works fine, too. Anyway, doing this gives (but see end of output)" bst <-
2013 Apr 18
1
select and do some calculations/manipulations on certain rows based on conditions in R
Hi, May be this helps (Assuming that there are only '0's and '1's in the dataset) dat1<-read.table(text=" ??????? ID X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 1?? 5184??? 0??? 0??? 0??? 0??? 0?? 0?? 0??? 0??? 0??? 1???? 0????? 0????? 0????? 0????? 0????? 0 2?? 6884??? 0??? 0??? 1??? 0??? 0?? 1?? 0??? 0??? 0??? 0???? 0????? 0????? 0????? 0????? 0????? 0 3?
2017 Aug 22
1
boot.stepAIC fails with computed formula
Failed? What was the error message? Cheers, 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 County" comic strip ) On Tue, Aug 22, 2017 at 8:17 AM, Stephen O'hagan <SOhagan at manchester.ac.uk> wrote: > I'm trying to use boot.stepAIC for
2017 Aug 22
0
boot.stepAIC fails with computed formula
The error is "the model fit failed in 50 bootstrap samples Error: non-character argument" Cheers, SOH. On 22/08/2017 17:52, Bert Gunter wrote: > Failed? What was the error message? > > Cheers, > > Bert > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka
2006 Aug 16
1
Specifying Path Model in SEM for CFA
I'm using specify.model for the sem package. I can't figure out how to represent the residual errors for the observed variables for a CFA model. (Once I get this working I need to add some further constraints.) Here is what I've tried: model.sa <- specify.model() F1 -> X1,l11, NA F1 -> X2,l21, NA F1 -> X3,l31, NA F1 -> X4,l41, NA F1 -> X5, NA, 0.20
2005 Oct 05
1
Ad: Re: R crashes for large formulas in lm() (PR#8180)
Dette er en melding med flere deler i MIME-format. --=_alternative 004613C000257091_= Content-Type: text/plain; charset="US-ASCII" And some more informastion I forgot. R does not crash if I write out the formula: set.seed(123) x1 <- runif(1000) x2 <- runif(1000) x3 <- runif(1000) x4 <- runif(1000) x5 <- runif(1000) x6 <- runif(1000) x7 <- runif(1000) x8 <-
2011 Feb 25
1
help please ..simple question regarding output the p-value inside a function and lm
Dear R community members and R experts I am stuck at a point and I tried with my colleagues and did not get it out. Sorry, I need your help. Here my data (just created to show the example): # generating a dataset just to show how my dataset look like, here I have x variables # x1 .........to X1000 plus ind and y ind <- c(1:100) y <- rnorm(100, 10,2) set.seed(201) P <-
2008 Mar 29
1
Tabulating Sparse Contingency Table
I have a sparse contingency table (most cells are 0): > xtabs(~.,data[,idx:(idx+4)]) , , x3 = 1, x4 = 1, x5 = 1 x2 x1 1 2 3 1 0 0 31 2 0 0 112 3 0 0 94 , , x3 = 2, x4 = 1, x5 = 1 x2 x1 1 2 3 1 0 0 0 2 0 0 0 3 0 0 0 , , x3 = 3, x4 = 1, x5 = 1 x2 x1 1 2 3 1 0 0 0 2 0 0 0 3 0 0 0 , , x3 = 1, x4
2010 Dec 14
2
How to bind models into a list of models?
Hi R-helpers, I have a character object called dd that has 32 elements each of which is a model formula contained within quotation marks. Here's what it looks like: > dd [1] "lm(y ~ 1,data=Cement)" "lm(y ~ X,data=Cement)" "lm(y ~ X1,data=Cement)" [4] "lm(y ~ X2,data=Cement)" "lm(y ~
2017 Aug 22
4
boot.stepAIC fails with computed formula
I'm trying to use boot.stepAIC for feature selection; I need to be able to specify the name of the dependent variable programmatically, but this appear to fail: In R-Studio with MS R Open 3.4: library(bootStepAIC) #Fake data n<-200 x1 <- runif(n, -3, 3) x2 <- runif(n, -3, 3) x3 <- runif(n, -3, 3) x4 <- runif(n, -3, 3) x5 <- runif(n, -3, 3) x6 <- runif(n, -3, 3) x7
2012 Jan 05
1
delete.response leaves response in attribute dataClasses
I posted this one as an R bug (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14767), but Prof. Ripley says I'm premature, and I should raise the question here. Here's the behavior I assert is a bug: The output from delete.response on a terms object alters the formula by removing the dependent variable. It removes the response from the "variables" attribute and it changes
2013 Apr 13
1
how to add a row vector in a dataframe
Hi, Using S=1000 and simdata <- replicate(S, generate(3000)) #If you want both "m1" and "m0" #here the missing values are 0 res1<-sapply(seq_len(ncol(simdata.psm1)),function(i) {x1<-merge(simdata.psm0[,i],simdata.psm1[,i],all=TRUE); x1[is.na(x1)]<-0; x1}) res1[,997:1000] #????? [,1]???????? [,2]???????? [,3]???????? [,4]??????? #x1??? Numeric,3000 Numeric,3000
2012 Sep 12
3
how to create a substraction matrix (subtract a row of every column from the same row in other columns)
Hello I have data like this x1 x2 x3 x4 x5 I want to create a matrix similar to a correlation matrix, but with the difference between the two values, like this x1 x2 x3 x4 x5 x1 x2-x1 x3-x1 x4-x1 x5-x1 x2 x3-x2 x4-x2 x5-x2 x3 x4-x3 x5-x3 x4 x5-x4 x5 Then I
2003 Oct 05
3
stepAIC problem
Dear R-users I have a probelm running stepAIC in R1.7.1 I wrote a program which used stepAIC as a part of it, and it worked fine while I was using the previous version of R1.7.0. However, I found the program did not work any more. Now, R produces a message which tells "Error in as.data.frame.default(data) : can't coerce function into a data.frame" every time I run the part of
2009 Aug 24
2
Formulas in gam function of mgcv package
Dear R-experts, I have a question on the formulas used in the gam function of the mgcv package. I am trying to understand the relationships between: y~s(x1)+s(x2)+s(x3)+s(x4) and y~s(x1,x2,x3,x4) Does the latter contain the former? what about the smoothers of all interaction terms? I have (tried to) read the manual pages of gam, formula.gam, smooth.terms, linear.functional.terms but
2009 Aug 24
2
Formulas in gam function of mgcv package
Dear R-experts, I have a question on the formulas used in the gam function of the mgcv package. I am trying to understand the relationships between: y~s(x1)+s(x2)+s(x3)+s(x4) and y~s(x1,x2,x3,x4) Does the latter contain the former? what about the smoothers of all interaction terms? I have (tried to) read the manual pages of gam, formula.gam, smooth.terms, linear.functional.terms but
2006 Aug 24
3
generating an expression for a formula automatically
Hi! I would like to be able to create formulas automatically. For example, I want to be able to create a function that takes on two values: resp and x, and then creates the proper formula to regress resp on x. My code: fit.main <- function(resp,x) { form <- expression(paste(resp," ~ ",paste(x,sep="",collapse=" + "),sep="")) z <-