Displaying 20 results from an estimated 10000 matches similar to: "linear regression in a data.frame using recast"
2011 Mar 16
1
linear regression in a data.frame using recast -- A fortunes candidate??
Ha! -- A fortunes candidate?
-- Bert
>
> If this is really a time series, then you will have serious validity
> problems due to auto-correlation among non-independent units. (But if you
> are just searching for a way to pull the wool over the eyes of the
> statistically uninformed, then I guess there's no stopping you.)
>
> --
>
> David Winsemius, MD
> West
2011 Nov 29
2
Help with recast() syntax
Dear Help-Rs,
I have data similar to the following:
DF <- structure(list(X = 1:22, RESULT = structure(c(2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), .Label = c("NEG", "POS"), class = "factor"), YR_MO = c(201011L,
201012L, 201101L, 201102L, 201103L, 201104L, 201105L, 201106L,
201107L, 201108L, 201109L, 201011L,
2012 Jul 27
1
Understanding the intercept value in a multiple linear regression with categorical values
Hi!
I'm failing to understand the value of the intercept value in a
multiple linear regression with categorical values. Taking the
"warpbreaks" data set as an example, when I do:
> lm(breaks ~ wool, data=warpbreaks)
Call:
lm(formula = breaks ~ wool, data = warpbreaks)
Coefficients:
(Intercept) woolB
31.037 -5.778
I'm able to understand that the value of
2020 May 02
1
issues with environment handling in model.frame()
Dear all,
model.frame behaves in a way I don't expect when both its formula and
subset argument are passed through a function call.
This works as expected:
model.frame(~wool, warpbreaks, breaks < 15)
#> wool
#> 14 A
#> 23 A
#> 29 B
#> 50 B
fun1 <- function(y) model.frame(~wool, warpbreaks, y)
fun1(with(warpbreaks, breaks < 15))
#> wool
#> 14
2010 May 18
2
how to select rows per subset in a data frame that are max. w.r.t. a column
Hi,
I'd like to select one row in a data frame per subset which is maximal for a
particular value. I'm pretty close to the solution in the sense that I can
easily select the maximal values per subset using "aggregate", but I can't
really figure out how to select the rows in the original data frame that are
associated with these maximal values.
library(stats)
# this
2011 Mar 21
2
string interpolation
Is there a way to do this in R? I have data in the form:
57_input 57_output 58_input 58_output etc.
can i use a for loop (i in 57:n) that plots only the outputs? I want
this to be robust so im not specifying a column id but rather
something like c++ code,
%s_input, i
is that doable in R?
Thanks,
justin
2011 May 31
2
count value changes in a column
is there a way to look for value changes in a column?
set.seed(144)
df<-data.frame(state=sample(rep(1:5,200),1000))
any of the five states are acceptable. however if, for example,
states 4 or 5 follow state 3, i want to overwrite them with 3.
changes from 1 to any value and 2 to any value are acceptable as are
changes from any value to 1 or 2.
By way of an example:
the sequence 1 3 3 5 5 3
2007 Aug 08
1
Change in R**2 for block entry regression
Hi all,
I'm demonstrating a block entry regression using R for my regression
class. For each block, I get the R**2 and the associated F. I do this
with separate regressions adding the next block in and then get the
results by writing separate summary() statements for each regression.
Is there a more convenient way to do this and also to get the change in
R**2 and associated F test for
2011 Jul 08
1
binary conversion list to data.frame with plyr... AND NO LOOPS!
Happy weekend helpeRs!
As usual, I'm stumped by R...
My plan was to take an integer number, convert it to binary and wind
up with a data.frame where each column is either 1 or 0 so I can see
which bits are changing:
bb<-function(i) ifelse(i, paste(bb(i %/% 2), i %% 2, sep=""), "")
my.dat<-c(36,40,10,4)
my.binary.dat<-bb(my.dat)
2011 Jun 17
3
rle on large data . . . without a for loop!
I think need to do something like this:
dat<-data.frame(state=sample(id=rep(1:5,each=200),1:3, 1000,
replace=T,prob=c(0.7,0.05,0.25)),V1=runif(1,10,1000),V2=rnorm(1000))
rle.dat<-rle(dat$state)
temp<-1
out<-data.frame(id=1:length(rle.dat$length))
for(i in 1:length(rle.dat$length)){
temp2<-temp+rle.dat$length[[i]]
out$V1[i]<-mean(dat$V1[temp:temp2])
2006 Feb 02
4
How to force a vector to be column or row vector?
Hi all,
I tended to use rbind, or cbind to force a vector be be deemed as a column
or row vector. This is very important if I want to do things like u' * A *
u, where u' is a row vector and u is a column vector, regardless of what
originall format the "u" is... I want to recast it to column vector or row
vector... How can I do that?
2009 Dec 04
5
logical masking of a matrix converts it to a vector
One problem I've been having is the special case in which only one
row/column remains and the variable gets converted into a vector when
entries are removed by logical masking. This is a problem because subsequent
code may rely on matrix operations (apply, colsums, dim, etc) For example:
> a <- matrix(c(1, 2, 3, 4), nrow = 2)
> a
[,1] [,2]
[1,] 1 3
[2,] 2 4
>
2010 Oct 13
2
[LLVMdev] [Q] x86 peephole deficiency
Am 07.10.2010 um 19:50 schrieb Chris Lattner:
>
> On Oct 6, 2010, at 6:16 PM, Gabor Greif wrote:
>
>> Hi all,
>>
>> I am slowly working on a SwitchInst optimizer (http://llvm.org/
>> PR8125)
>> and now I am running into a deficiency of the x86
>> peephole optimizer (or jump-threader?). Here is what I get:
>>
>>
>> andl $3,
2005 Oct 26
1
Post Hoc Groupings
Quick question, as I attempt to learn R. For post-hoc tests
1) Is there an easy function that will take, say the results of
tukeyHSD and create a grouping table. e.g., if I have treatments 1, 2,
and 3, with 1 and 2 being statistically the same and 3 being different
from both
Group Treatment
A 1
A 2
B 3
2) I've been stumbling over the proper syntax for simple effects for a
tukeyHSD
2009 Jan 14
3
Casting lists to data.frames, analog to SAS
I have a specific question and a general question.
Specific Question: I want to do an analysis on a data frame by 2 or more
class variables (i.e., use 2 or more columns in a dataframe to do
statistical classing). Coming from SAS, I'm used to being able to take a
data set and have the output of the analysis in a dataset for further
manipulation. I have a data set with vote totals, with one
2011 Apr 27
3
MASS fitdistr with plyr or data.table?
I am trying to extract the shape and scale parameters of a wind speed
distribution for different sites. I can do this in a clunky way, but
I was hoping to find a way using data.table or plyr. However, when I
try I am met with the following:
set.seed(144)
weib.dist<-rweibull(10000,shape=3,scale=8)
weib.test<-data.table(cbind(1:10,weib.dist))
2010 Oct 13
0
[LLVMdev] [Q] x86 peephole deficiency
On Oct 13, 2010, at 11:22 AM, Gabor Greif wrote:
> Hi Chris,
>
> I had a look into MachineCSE, but it looks like MBB-oriented.
> The above problem is an inter-block one. Also MCSE seems
> to perform value numbering on virtual/physical registers, which
> does not map very well to status register bits that are implicitly
> defined.
> Any chance to recast this issue as a
2006 Nov 15
1
Regression
I need to run a regression analysis with a large number of samples. Each
sample (identified in the first file column) has its own x and y values. I
will use the same model in all samples. How can I run the model for each
sample? In SAS code I would use the "BY SAMPLE" statement.
Alvaro
[[alternative HTML version deleted]]
2012 Jul 25
2
reshape -> reshape 2: function cast changed?
Hi,
I used to use reshape and moved to reshape2 (R 2.15.1). Now I tried some of my older scripts and was surprised that my cast function wasn't working like before.
What I did/want to do:
1) Melt a dataframe based on a vector specifying column names as measure.vars. Thats working so far:
dfm <- melt(df, measure.vars=n, variable_name = "species", na.rm = FALSE)
2) Recast the
2009 May 23
1
Constraining linear regression model
Hi All,
I have two questions:
I am computing a linear regression model with 0 as Intercept.
Well, I would like the sum of my predicted values be equal to a constant
and therefore analyze if my coefficients are significatively different
using or not this constraint.
Does anyone know how I can constrain my model in a such way?
Here is the code:
data<-read.table ("input.txt",