Displaying 8 results from an estimated 8 matches for "100,2,1".
Did you mean:
100,0,1
2010 Jan 29
1
SemiPar/spm question
...ems to be attached to the wrong thread. Also, I extended my test a little and it seems to indicate the problem is with spm. I would appreciate any help. Thanks.
==========================================================
library(plyr)
library(SemiPar)
data <- data.frame(id=c(rep("111",100),rep("222",200)), value=c(rnorm(100,2,1),rnorm(200,10,5)), lhs=c(rnorm(100,2,1),rnorm(200,10,5)))
#this works
d_ply(data, c("id"), function(x) {
print(lm("lhs~value", data=x))
})
#this works
data111 <- data[data$id=="111",]
print(spm(data111$value ~...
2012 Feb 22
2
Several densityplots in single figure
Hi,
I have created two separate overlapping density plots- see example code
below.
What I wish now to do is combine them into one figure where they sit side
by side.
Any help would be great!
many thanks in advance, josh.
#####################
thedataA <- data.frame(x1=rnorm(100,1,1),x2=rnorm(100,3,1)) #create data
thedataA.m<-melt(thedataA)
densityplot(~value, thedataA.m, groups=variable,auto.key=list(columns=2),
panel = function(x, y, ...) {
panel.densityplot(x, ...)
panel.abline(v=0)
}
)
thedataB <- data.frame(x1=rnorm...
2010 Nov 15
3
How to plot effect of x1 while controlling for x2
...tion that does the same thing, without having to
specify that x2 should be held at its mean value? It works fine for
this simple example, but might be cumbersome if the model was more
complex (e.g., lots of x variables, and/or interactions).
Many thanks,
Mark
#make some random data
x1<-rnorm(100)
x2<-rnorm(100,2,1)
y<-0.75*x1+0.35*x2
#fit a model
model1<-lm(y~x1+x2)
#predict the effect of x1 on y, while controlling for x2
xv1<-seq(min(x1),max(x1),0.1)
yhat_x1<-predict(model1,list(x1=xv1,x2=rep(mean(x2),length(xv1))),type="response")
#plot the predicted values
pl...
2003 Oct 15
1
fivenum (PR#4586)
Full_Name: Richard Huggins
Version: 1.7.1
OS: windows 2000
Submission from: (NULL) (131.172.4.44)
> x<-rnorm(100,2,1)
> mean(x)
[1] 1.73299
> summary(fivenum(x))
Min. 1st Qu. Median Mean 3rd Qu. Max.
-0.3655 1.1070 1.7430 1.7320 2.3840 3.7910
> summary(x)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-0.3655 1.1070 1.7430 1.7330 2.3830 3.7910
> y<-log(abs(x))
> summ...
2011 Aug 02
1
Need to compute density as done by panel.histogram
...s the density
function but the actual code suggests that the hist.constructor function
(which does not seem to be easily accessible).
Any suggestion for computing the density values of foo$x in the following
example will be welcome.
require(lattice)
set.seed(12345)
foo1 <-
data.frame(x=rnorm(100,0,0.1),grp=1,by=rep(1:2,each=50),by2=rep(1:2,times=50))
foo2 <-
data.frame(x=rnorm(100,2,1),grp=2,by=rep(1:2,each=50),by2=rep(1:2,times=50))
foo <- rbind(foo1,foo2)
xplot <- histogram(~x,data=foo, type='density')
PS: the present question relates to a workaround for another probl...
2010 Oct 22
1
lm looking for weights outside of the user-defined function
Dear R'ers,
I am fighting with a problem that is driving me crazy. I use "lm" in
my user-defined function, but it seems to be looking for weights
outside of my function's environment:
### Generating example data:
x<-data.frame(y=rnorm(100,0,1),a=rnorm(100,1,1),b=rnorm(100,2,1))
myweights<-runif(100)
data.for.regression<-x[1:3]
### Creating function "weighted.reg":
weighted.reg=function(formula, MyData, filename,WeightsVector)
{
print(dim(MyData))
print(filename)
print(length(WeightsVector))
regr.f<-lm(formula...
2011 Jul 27
1
How to adjust y-axis when using panel.densityplot within histogram function
...tempts. Is
this the way to go, or should I calculate the range outside the histogram
call using some stat function (density?) on each group and use it as a ylim
argument?
Any advise would be greatly appreciated.
Thank you
Sebastien
require(lattice)
set.seed(12345)
foo1 <- data.frame(x=rnorm(100,0,0.1),grp=1)
foo2 <- data.frame(x=rnorm(100,2,1),grp=2)
foo <- rbind(foo1,foo2)
#
# Some code to calculate ylim...
#
histogram(~x,data=foo,groups=grp,
#prepanel=function(x,type,groups,...){???},
panel=function(x,type,groups,...){
panel.histogram(x,col='transparent',...)...
2011 May 03
3
fitting distributions using fitdistr (MASS)
Please guide me through to resolve the error message that I get
this is what i have done.
>x1<- rnorm(100,2,1)
>x1fitbeta<-fitdistr(x1,"beta")
Error in fitdistr(x1, "beta") : 'start' must be a named list
Yes, I do understand that sometime for the distribution to converge to the
given set of data, it requires initial parameters of the distribution, to
start off with. H...