search for: xvar

Displaying 20 results from an estimated 64 matches for "xvar".

Did you mean: var
2007 Jun 14
4
question about formula for lm
Dear all; Is there any way to make this to work?: .x<-rnorm(50,10,3) .y<-.x+rnorm(50,0,1) X<-data.frame(.x,.y) colnames(X)<-c("Xvar","Yvar") Ytext<-"Yvar" lm(Ytext~Xvar,data=X) # doesn't run lm(Yvar~Xvar,data=X) # does run The main idea is to use Ytext as input in a function, so you just type "Yvar" and the model should fit.... Also, I need to avoid the expression X$Yvar~X$Xvar Tha...
2005 Jul 05
1
by (tapply) and for loop differences
...I've attached a simple example below to illustrates my problem. I get a difference in the mean of yvar, diff and the p-value using tapply & by compared to a for loop. I cannot see what I am doing wrong. Can anyone help? > # Simulate some data - I'll do 2 simulations... > > xvar = rnorm(40, 20, 5) > yvar = rnorm(40, 22, 2) > num = factor(rep(1:2, each=20)) > sdat = data.frame(cbind(num, xvar, yvar)) > > # Define a function to do a simple t test and return some values... > > kindtest = function(varx, vary){ + res = t.test(varx, vary) + x.mn = re...
2003 Jan 22
1
something wrong when using pspline in clogit?
...be wrong). The strange thing here is that even the intercepts are the same. Lastly, these coefficients are the same as using clogit before adding the constant, but the intercept are different. I have attached my code for all this, maybe I messed it somewhere. Vumani ########################## xvar<-rnorm(100,0,1) data.mult<-rbinom(100,size=3,prob=(exp(0.5+0.4*xvar)/(1+exp(0.5+0.4*xvar)))) library(Nnet) mult.fit<-multinom(data.mult~xvar) coef(mult.fit) library(survival) choice<-c(ifelse(data.mult==0,1,0),ifelse(data.mult==1,1,0),ifelse(data.mult==2,1,0),ifelse(data.mult==3,1,0)) t...
2011 Feb 25
1
speed up process
...nt my problem). It might also look too complex for what it is intended to do, but my colleagues who are also supposed to use it don't know much about R. So I wrote it so that they don't have to modify the critical parts to run the script for their needs. #column indexes for function ind.xvar <- 2 seq.yvar <- 3:4 #position vector for legend(), stupid positioning but it doesn't matter here mypos <- c("topleft", "topright","bottomleft") #run the function for columns 3&4 as y (seq.yvar) with column 2 as x (ind.xvar) for all 3 datasets (mydat...
2012 Aug 11
1
using eval to handle column names in function calling scatterplot graph function
I am running R version 2.15.1 in Windows XP I am having problems with a function I'm trying to create to: 1. subset a data.frame based on function arguments (colname & parmname) 2. rename the PARMVALUE column in the data.frame based on function argument (xvar) 3. generate charts plotvar <- function(parentdf,colname, parmname,xvar,yvar ){ subdf <- parentdf[substr(colname,1,nchar(parmname)) == parmname,] names(subdf) <- sub('PARMVALUE',xvar, names(subdf)) xvarcol <- paste("subdf","$",xvar,sep=&q...
2019 May 25
3
Increasing number of observations worsen the regression model
I have the following code: ``` rm(list=ls()) N = 30000 xvar <- runif(N, -10, 10) e <- rnorm(N, mean=0, sd=1) yvar <- 1 + 2*xvar + e plot(xvar,yvar) lmMod <- lm(yvar~xvar) print(summary(lmMod)) domain <- seq(min(xvar), max(xvar))??? # define a vector of x values to feed into model lines(domain, predict(lmMod, newdata = data.frame(xvar=domain)...
2009 Apr 21
6
Sampling in R
[This email is either empty or too large to be displayed at this time]
2007 Nov 15
1
Writing a helper function that takes in the dataframe and variable names and then does a subset and plot
...(x,y,lwd=2,col.line='red', ...) }, xlab = xylabels[1], ylab= xylabels[2]) } plotwithfits(Latency ~ Stimulus.number | Subject.ID,eye_subsetted_data) # Works However, I can't get it working if I try the same for a subset and plot: explorebysubject <- function(xvar,yvar,data,condition=TRUE,xlim=c(-Inf,Inf),ylim=c(-Inf,Inf)) { temp_subset <- subset(data, subset=condition&xvar>xlim[1]&xvar<xlim[2]&yvar>ylim[1]&yvar<ylim[2], select=c(Group,Subject.ID,xvar,yvar)...
2011 Apr 01
3
programming: telling a function where to look for the entered variables
...wever, I'd like to use the same function for different dataframes and variables. My problem is that I'm not quite sure how to tell my function in which dataframe the entered variables are located. Here's some reproducible data and the function: # create reproducible data set.seed(124) xvar <- sample(0:3, 1000, replace = T) yvar <- sample(0:1, 1000, replace=T) zvar <- rnorm(100) lvar <- sample(0:1, 1000, replace=T) Fulldf <- as.data.frame(cbind(xvar,yvar,zvar,lvar)) Fulldf$xvar <- factor(xvar, labels=c("blue","green","red","yellow&q...
2011 Mar 05
2
please help ! label selected data points in huge number of data points potentially as high as 50, 000 !
...my problem is real issue and I have been working on this. I know this might be simple to those who know it ! Anyway I need help ! Let me clear my point. I have huge number of datapoints plotted using either base plot function or xyplot in lattice (I have preference to use lattice). name xvar p 1 M1 1 0.107983837 2 M2 11 0.209125624 3 M3 21 0.163959428 4 M4 31 0.132469859 5 M5 41 0.086095130 6 M6 51 0.180822010 7 M7 61 0.246619925 8 M8 71 0.147363687 9 M9 81 0.162663127 ........ 5000 observation...
2011 Aug 30
1
R crash
...ff(). Is there anything else than sessionInfo()? Thank you for your help, Ivan -------- script --------- library(R.utils) library(RSvgDevice) library(doBy) primate_med <- loadObject("primate_med.Rbin") select <- primate_med #data object to use seq.yvar <- c(5,12,8,9) ind.xvar <- 4 filename <- paste("regression", names(datobj)[ind.xvar], paste(names(datobj)[seq.yvar],collapse="_"), paste(selvarstr,collapse="_"), sep="_") filename <- gsub(".median", "", filename) select_mean <- summaryBy(as...
2011 Feb 28
0
Fwd: Re: speed up process
...ta2<- mydata1[!(mydata1$species %in% c("thgel","alsen")),] mydata3<- mydata1[!(mydata1$species %in% c("thgel","alsen","poabe")),] mydata_list<- list(mydata1=mydata1, mydata2=mydata2, mydata3=mydata3) library(WRS) foo_reg<- function(dat, xvar, yvar, mycol, pos, name.dat){ tsts<- tstsreg(dat[[xvar]], dat[[yvar]]) tsts_inter<- signif(tsts$coef[1], digits=3) tsts_slope<- signif(tsts$coef[2], digits=3) abline(tsts$coef, lty=1, col=mycol) legend(x=pos, legend=c(paste("TSTS ",name.dat,": Y=",tsts_inter,...
2005 Dec 26
4
lme X lmer results
Hi, this is not a new doubt, but is a doubt that I cant find a good response. Look this output: > m.lme <- lme(Yvar~Xvar,random=~1|Plot1/Plot2/Plot3) > anova(m.lme) numDF denDF F-value p-value (Intercept) 1 860 210.2457 <.0001 Xvar 1 2 1.2352 0.3821 > summary(m.lme) Linear mixed-effects model fit by REML Data: NULL AIC BIC logLik 5416.59 5445.256 -2702.29...
2012 Sep 20
1
Gummy Variable : Doubt
...es (H1: equal mesor, H2.x: equal amplitude and acrophase, H3: equal rhythmic components). I suppose I have to use dummy variables, but I don’t know how to do it.   I could access something similar in a solution manual of  a Weisberg book (1985), chapter 6, problem 9, as follows: m1 <- lm(Yvar~ Xvar + Fvar + Fvar:Xvar, na.action=na.omit, weights=theWeights)  # this is model 1 the most general m2 <- lm(Yvar~ Xvar + Fvar            , na.action=na.omit, weights=theWeights)  # this is model 2 parallel m3 <- lm(Yvar~ Xvar + Fvar:Xvar       , na.action=na.omit, weights=theWeights)  # this is...
2011 Oct 12
2
Nonlinear regression aborting due to error
Colleagues, I am fitting an Emax model using nls. The code is: START <- list(EMAX=INITEMAX, EFFECT=INITEFFECT, C50=INITC50) CONTROL <- list(maxiter=1000, warnOnly=T) #FORMULA <- as.formula(YVAR ~ EMAX - EFFECT * XVAR^GAMMA / (XVAR^GAMMA + C50^GAMMA)) ## alternate version of formula FORMULA <- as.formula(YVAR ~ EMAX - EFFECT / (1 + (C50/XVAR)^GAMMA)) FIT <- nls(FORMULA, start=START, control=CONTROL, trace=T) If GAMMA equals 10-80, nls converges successfully and the fit tracks the fit from a smoother...
2011 Mar 05
1
displaying label meeting condition (i.e. significant, i..e p value less than 005) in plot function
Dear R users, Here is my problem: # example data name <- c(paste ("M", 1:1000, sep = "")) xvar <- seq(1, 10000, 10) set.seed(134) p <- rnorm(1000, 0.15,0.05) dataf <- data.frame(name,xvar, p) plot (dataf$xvar,p) abline(h=0.05) # I can know which observation number is less than 0.05 which (dataf$p < 0.05) [1] 12 20 80 269 272 338 366 368 397 403 432 453 494 543 592 691 723...
2007 May 23
1
name of object in quotes
I am writing a function in which, at some point, I to recuperate the name of a previous object in quotes. I am currently using the function Cs() from the Hmisc library but the result is: foo <- function(xvar) { variable <- Cs(xvar) return(variable) } foo(x1) > "xvar" when I would expected to obtain "x1". Any suggestion? Thanks -- *Gonzalo Rivero* Ph.D. candidate Centro de Estudios Avanzados en Ciencias Sociales Juan March Institute Castell? 77, 2nd floor 28006,...
2009 Feb 27
1
Sweave doesn't do csv.get()
...X. I set up LyX 1.6.1 to use Sweave today. I can compile the test file I found on CRAN ( http://cran.r-project.org/contrib/extra/lyx/) without a problem and the output looks very nice. In the test file the following R code is used. <<myFirstChunkInLyX>>= xObs <- 100; xMean <- 10; xVar <- 9 x <- rnorm(n=xObs, mean=xMean, sd=sqrt(xVar)) mean(x) @ that should be the same as: xObs <- 100 xMean <- 10 xVar <- 9 x <- rnorm(n=xObs, mean=xMean, sd=sqrt(xVar)) mean(x) in the R console. My problem is that I want to import data to use in my report. In the R source I cu...
2011 Apr 30
1
More flexible aggregate / eval
...ith(d2, ave(x1, list(group2, time), FUN = function(x) round(prop.table(x) * 100, 1) ) ) op2 <- xtabs(l_pct ~ group2 + ids + time, data = d2) ftable(op2, row.vars=c(1,3)) ## and for group3... ## To have a more flexible solution I wrote this function: myfun <- function(xdf, xvar) { fo1 <- "cbind(x1, x2) ~ " fo2 <- paste(fo1, xvar, "+ ids + time", sep="") formular <- as.formula(fo2) d2 <- do.call(aggregate, list(formular, data = xdf, FUN = sum)) d2$l_pct <- with(d2, ave(x1, list(eval(as.name(xvar)), time),...
2012 Jun 25
3
Loop for multiple plots in figure
...n't figure out how to get each of the subjects to plot separately, could not figure it out from the existing posts. For now I want to do this in the basic environment though I know that lattice could also work (might try that later). Any help appreciated tC <- textConnection(" Subject Xvar Yvar param1 param2 bob 9 100 1 100 bob 0 250 1 200 steve 2 454 1 50 bob -5 271 0 35 bob 3 10 0 74 steve 1 500 1 365 kevin 5 490 1 546 bob 8 855 0 76 dave 2 233 0 343 steve -10 388 0 556 steve -7 284 1 388 dave 3 568 1 555 kevin 4 247 0 57 bob 6 300 1 600 ") data <- read.table(header=TRUE, t...