Displaying 20 results from an estimated 32 matches for "thedata".
2007 Aug 13
0
R^2 for multilevel models
...below.
Many thanks,
Andy
#################################################################
require(lme4)
# First generate some data
people = 100
obs = 4
# The random intercepts:
sub_noise = data.frame(id = 1:people, rand_int = rnorm(people,0,60))
# Merge everything
id = rep(1:people,obs)
thedata = data.frame(id)
thedata = merge(sub_noise, thedata)
thedata$x = rep(1:obs,people)
# Setup the relationship between x and y
thedata$y = 23*thedata$x + 20 + thedata$rand_int
+ rnorm(people*obs, 0, 20) # plus residuals
# Have a look
plot(y~x, data = thedata)
# Now fit a standard r...
2009 Jul 03
1
The time series analysis functions/packages don't seem to like my data
...e hundreds of megabytes of price data time series, and perl
scripts that extract it to tab delimited files (I have C++ programs
that must analyse this data too, so I get Perl to extract it rather
than have multiple connections to the DB).
I can read the data into an R object without any problems.
thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
= FALSE, na.strings="")
thedata
The above statements give me precisely what I expect. The last few
lines of output are:
8190 2009-06-16 49.30
8191 2009-06-17 48.40
8192 2009-06-18 47.72
8193 2009-06-19 48....
2007 Oct 08
0
Residuals for binomial lmer fits
...require(lme4)
set.seed(0)
# Data for 100 people, each of whom has 10 observations
people = 100
obs = 10
# Generate person-level variation
sub_noise = data.frame(id = 1:people, rand_int = rnorm(people,0,60))
# And within person noise
resids = rnorm(people*obs, 0, 20)
id = rep(1:people,obs)
thedata = data.frame(id)
thedata = merge(sub_noise, thedata)
thedata$x = rep(1:obs,people)
thedata$y = 23*thedata$x + 20 + thedata$rand_int + resids
thedata$y.flat = 23*thedata$x + 20 + resids
# Fit a random intercept model
lmer1 = lmer(y ~ x + (1|id), data=thedata)
summary(lmer1)
# Get the intercepts...
2012 Jan 04
1
Adding a vertical line to plot with two overlapping density plots
Hi,
A simple question I hope. I wish to add a single vertical line to a plot
with several density plots.
Here is a simplified example.
############
thedata <- data.frame(x1=rnorm(100,1,1),x2=rnorm(100,3,1)) #create data
thedata.m<-melt(thedata)
densityplot(~value, thedata.m, groups=variable,auto.key=list(columns=2))
#this gives the two density plots
#########
what I wish now is to add a vertical line, for example v=2.
Many thanks,
Josh.
[[al...
2018 Jan 24
4
Geometry delaunayn and deldir results, differing results from Octave due to decimal precision?
...s a set of variables exported from Octave 'x y tri xiflat yiflat tri_list.mat'
https://pastebin.com/xELkj6r6
the variable tri_list is just the tri_list = search(x,y,tri_deldir,xiflat,yiflat) in Octave
The command history is a as follows:
library(deldir)
library(geometry)
library(foreign)
theData <- read.octave('x y tri xiflat yiflat tri_list.mat')
options(digits = 10)
x <- unlist(theData[1])
y <- unlist(theData[3])
tri_deldir <- triMat(deldir(x,y))
tri_delaunayn <- delaunayn(x,y)
tri_delaunayn <- delaunayn(cbind(x,y))
tri_list_from_deldir <- tsearch(x,y,tri_del...
2006 Mar 11
2
how to create analog stripchart plots of x vs t (t=mm/dd/yyyy hh:mm:ss)
...quot;,"15:06",0.000000
...etc...
I am trying to make a plot of 'X' vs. 't'
where 'x' is a simple numerical vector of N elemets
and 't' is a timestamp like "mm/dd/yyyy hh:mm:ss"
(also of N elements)
here is how i am getting the data:
>
>TheData <- scan("MyDataFile.txt",sep=",",list("","",0))
>TheDates <- TheData[[1]]
>TheTimes <- TheData[[2]]
>TheValue <- TheData[[3]]
>
and here is how i am making the datetime objects:
>
>TimeStampStr <- paste(TheDates,TheTimes...
2008 Jul 16
1
Problem with mpi.close.Rslaves()
...t doesn't
already?
mpirun -np 4 -machinefile /var/spool/PBS/aux/90361.head
/apps/R/R270/bin/R CMD BATCH --save Rmpi_test4.R
# Initialize MPI
library("Rmpi")
# Function the slaves will call to perform a validation on the
# fold equal to their slave number.
# Assumes: thedata,fold,foldNumber,p
foldslave <- function() {
# Note the use of the tag for sent messages:
# 1=ready_for_task, 2=done_task, 3=exiting
# Note the use of the tag for received messages:
# 1=task, 2=done_tasks
junk <- 0
done <- 0
while (done !...
2008 Nov 07
1
Rmpi task-pull
...close.Rslaves() to close slaves.")
mpi.close.Rslaves()
}
print("Please use mpi.quit() to quit R")
.Call("mpi_finalize")
}
}
# Function the slaves will call to perform a validation on the
# fold equal to their slave number.
# Assumes: thedata,fold,foldNumber,p
foldslave <- function() {
# Note the use of the tag for sent messages:
# 1=ready_for_task, 2=done_task, 3=exiting
# Note the use of the tag for received messages:
# 1=task, 2=done_tasks
junk <- 0
done <- 0
while (done != 1) {
#...
2011 Oct 18
2
Non-linear maximization function in R
...'m very confident
that this equation is working properly. I would expect the outputs of this
function to be roughly equivalent to the results from object "p" as seen
above, but they don't look similar at all. I'm not sure what this means.
tBLparamsForOneSpecies <- function(theData) {
x <- theData[ ,1]
y <- theData[ ,2]
logitReg <- glm(y ~ x + I(x^2), family=binomial)
b0 <- logitReg$coefficients[1]
b1 <- logitReg$coefficients[2]
b2 <- logitReg$coefficients[3]
opt <- (-b1)/(2*b2)
tol <- 1 / sqrt(-2*b2)
pmax<-1/(1+exp(b1^2/(4*b2)-b0))
thePar...
2009 Apr 28
1
[macosx] improving quartz & Aqua Tk behaviour outside of RGui
Hello,
On Mac OS X, certain Aqua/Quartz UI functionality requires an
application to be launched from within an app bundle, or
(alternatively) requires a Carbon application with a resource fork.
Playing with the wxWidgets distribution, I discovered that it is quite
easy and transparent to make such a Carbon app from (I guess) any
command line application. When applied to the R executable called
2009 Apr 28
1
[macosx] improving quartz & Aqua Tk behaviour outside of RGui
Hello,
On Mac OS X, certain Aqua/Quartz UI functionality requires an
application to be launched from within an app bundle, or
(alternatively) requires a Carbon application with a resource fork.
Playing with the wxWidgets distribution, I discovered that it is quite
easy and transparent to make such a Carbon app from (I guess) any
command line application. When applied to the R executable called
2007 Jul 20
1
Column-mean-values for targeted rows
Hi all,
I'm handling massive data.frames and matrices in R (30000 x 400).
In the 1st column, say, I have 0s and 1s indicating rows that matter; other columns have probability values.
One simple task I would like to do would be to get the column mean values for signaled rows (the ones with 1)
As a very fresh "programmer" I have build a simple function in R which should not be very
2018 Jan 24
0
Geometry delaunayn and deldir results, differing results from Octave due to decimal precision?
...ri xiflat yiflat tri_list.mat'
> https://pastebin.com/xELkj6r6
>
> the variable tri_list is just the tri_list = search(x,y,tri_deldir,xiflat,yiflat)
> in Octave
>
>
> The command history is a as follows:
> library(deldir)
> library(geometry)
> library(foreign)
> theData <- read.octave('x y tri xiflat yiflat tri_list.mat')
> options(digits = 10)
> x <- unlist(theData[1])
> y <- unlist(theData[3])
> tri_deldir <- triMat(deldir(x,y))
> tri_delaunayn <- delaunayn(x,y)
> tri_delaunayn <- delaunayn(cbind(x,y))
> tri_list_fr...
2013 Feb 12
0
error message from predict.coxph
...a1 <- 0.2 # event rate in group 1
t0 <- 10 # time to estimate expected numbers of events
# 'correct' number of events at time t0 = rate of events (lambda) times time (t0)
t0*lambda0
t0*lambda1
# generate uncensored data
T0 <- rexp(nn, rate=lambda0)
T1 <- rexp(nn, rate=lambda1)
thedata <- data.frame(Time=c(T0, T1), X=rep(0:1, e=nn), X2=rep(0:1, nn))
# 4 covariate combinations
(ndf <- data.frame(Time=t0, X=rep(0:1,e=2), X2=rep(0:1, 2)))
# model with 2 effects
mod <- coxph(Surv(Time) ~ X + X2, data=thedata)
summary(mod)
# coefficient of X2 should be 0
# coefficient of X...
2007 Jul 06
2
access to 'formula' terms in a user function
...uestion is on scripting basics). For
purposes of figuring out my needs, lets just consider writing a function
that takes a formula and a dataset, and outputs the mean of each variable in
the formula model. So:
MyFunction <- function(AFormula, ADataFrame) {
...
}
>MyFunction(Y ~ A + B, TheData)
would give results something like:
Mean of MyData$Y is 5.3
Mean of MyData$A is 3.4
Mean of MyData$B is 8.2
QUESTION 1:
How do I determine the terms in the formula within the function?
QUESTION 2:
How do I use one of those terms to get to the individual columns, like
MyData$Y ?
Thanks!
-E...
2006 Jul 07
1
densityplot and panel.groups
I am trying to plot multiple densityplots on each panel, and using
panel.groups to do some additional plotting (not included in the
example) as in this example.
library(lattice)
thedata <- data.frame(x=rnorm(1200),class=rep(1:3,each=200,times=2),
group=rep(1:2,each=100,times=6))
densityplot(~x | class,groups=group,
xlab='x',
panel.groups = function(x,subscripts,groups,panel.number,...) {
panel.densityplot(x=x,subscripts=subscripts,groups=groups,...)
# other stuff...
2010 Aug 18
2
Different way of aggregating
Hi
Usually "aggregate" is used to calculate things such as the sum of all data
on the first day, the sum next day, and so on.
But how can I calculate the mean of the first hour of all days, the mean of
the second hour of all days, and so on. ???
That's
Most examples:
today at 1am + today at 2am + today at 3am +.... -> sum
today
tomorrow at 1am + tomorrow at
2018 Jan 25
0
Geometry delaunayn and deldir results, differing results from Octave due to decimal precision?
...ri xiflat yiflat tri_list.mat'
> https://pastebin.com/xELkj6r6
>
> the variable tri_list is just the tri_list = search(x,y,tri_deldir,xiflat,yiflat)
> in Octave
>
>
> The command history is a as follows:
> library(deldir)
> library(geometry)
> library(foreign)
> theData <- read.octave('x y tri xiflat yiflat tri_list.mat')
> options(digits = 10)
> x <- unlist(theData[1])
> y <- unlist(theData[3])
> tri_deldir <- triMat(deldir(x,y))
> tri_delaunayn <- delaunayn(x,y)
> tri_delaunayn <- delaunayn(cbind(x,y))
> tri_list_fr...
2006 Feb 07
2
Question about Classes.
...s[j].nodeType !=
1) continue
try {
//this.sdEventInfo[ei[0].childNodes[j].nodeName] =
ei[0].childNodes[j].firstChild.nodeValue;
//this.options.sdEventInfo.push(ei[0].childNodes[j].firstChild.nodeValue
);
var theData =
ei[0].childNodes[j].firstChild.nodeValue;
} catch (e) {
var theData = " ";
$(''debug'').innerHTML +=
e+"<br />";
//th...
2009 Nov 29
1
Convergence problem with zeroinfl() and hurdle() when interaction term added
Hello,
I have a data frame with 1425 observations, 539 of which are zeros. I
am trying to fit the following ZINB:
f3<-formula(Nbr_Abs~ Zone * Year + Source)
ZINB2<-zeroinfl(f3, dist="negbin", link= "logit", data=TheData,
offset=log(trans.area), trace=TRUE)
Zone is a factor with 4 levels, Year a factor with 27 levels, and
Source a factor with 3 levels. Nbr_Abs is counts of a species that
shows a high level of aggregation. These counts are offset by the area
searched per transect.
The trace output and error messag...