Displaying 20 results from an estimated 600 matches similar to: "Lasso with Categorical Variables"
2011 Feb 01
2
Preparing dataset for glmnet: factors to dummies
Hello list.
For some reason, the makers of glmnet do not accept a dataframe as input.
They expect the input to be a matrix, where the dummies are already
precoded.
Now I have created a sample dataset with
. 11 factor columns with two levels
. 4 factor columns with three levels
. 135 continuous columns (from a standard normal)
. 100 observations (rows)
Say this dataframe is in dfrPredictors.
What
2011 Dec 07
1
Help! I couldn't put multiple qplot on the same page...
Hi all,
I am stuck at ploting multiple graphs on one page. I don't why it doesn't work.
All the 6 plots are either exactly the same, or they simply don't plot
at all. I made sure that in each iteration the "datasub" and
"factorsub" are different ...
Could you please help me?
Thanks a lot!
I did my homework and followed the following advice:
2011 Apr 07
1
transform() on selective names. Is it possible?
Hi all,
I am whitening my data:
# code begins
N <- 300
M <- 2
x <- matrix(data=rnorm(N*M, 0, 3)-10, ncol=M, nrow=N)
y <- matrix(c(1,-2,-2,1), ncol=M, nrow=M)
z <- data.frame(x %*% y)
colnames(z) <- c('x','y')
par(mfrow=c(1,3))
plot(z, pch=5, col="blue")
whiten <- function(x) { (x-mean(x))/sd(x) }
zz <- transform(z, x=whiten(x), y=whiten(y))
2013 Mar 25
3
nested 'while' loops
Hi everyone,
I'm using the following code to go over every element of a data frame (row
wise). The problem I am facing is that the outer 'x' variable is not
incrementing itself, thus, only one row of values is obtained, and the
program does not proceed to the next row.
This is the code:
while(x<=coln)
{
while(y<=rown)
{
n<-as.numeric(df[[y]][x]);
2006 Apr 04
1
Help on computing a matrix from another matrix in R
Hello All,
I am new to R and am having a problem.
I have the following 29 x 5 array called temp with a mode "list".
Sincere Exciting Competent Sophisticated Rugged
3.5 2.5 3.8 3.5 3.0
2.0 2.5 3.5 2.5 2.3
2.8 3.0 2.3 1.5 1.8
2.0 4.0 2.8 1.5 4.5
2.5 1.5 1.8 1.3 1.3
2009 Dec 14
1
as.data.frame requires a lot of memory (PR#14140)
Full_Name: Raimar Falke
Version: R version 2.10.0 (2009-10-26)
OS: Linux 2.6.27-16-generic #1 SMP Tue Dec 1 19:26:23 UTC 2009 x86_64 GNU/Linux
Submission from: (NULL) (134.102.222.56)
The construction of a data frame in the way shown below requires
much more memory than expected. If we assume a cell value takes 8 bytes
the total amount of the data is 128mb. However the process takes about
2009 May 09
2
Sweave \Sexpr{} advice please
Dear List,
First off, my deepest gratitude to the Sweave developers: this tool has
improved my quality greatly.
A question in my work I use \Sexpr{} statements scalar values and the xtable
package for all manner of tables. What I'd like to do is to use a vector
inline, rather than a whole separate table. Something like:
%%%%%%%%%%%%%%%% begin code
% Latex junk
% Sweave block:
2015 Feb 24
2
intercalar elementos de vectores
Excelente! Ahora corre muy rápido. No conocía ese método, creo que me va a
resultar muy útil.
Muchas gracias y saludos.
Fernando Macedo
El 24/02/15 a las 10:51, Jorge I Velez escribió:
Fernando,
Podrias intentar
R> a <- rep('a', 5)
R> b <- rep('b', 5)
R> a
[1] "a" "a" "a" "a" "a"
R> b
[1] "b"
2004 Sep 16
5
Indexing lists
DeaR useRs:
I have a list with 500 elements, in each other there are data.frames and I
want to take the first row and the first column of each elements of my list
since the first to the 500-th.
Thanks and excuse my bad English.
---
[[alternative HTML version deleted]]
2007 Jun 26
1
A really simple data manipulation example
In response to those who asked for a better explanation of what the
Vilno software does, here's a simple example that gives some idea of
what it does.
LABRESULTS is a dataset with multiple rows per patient , with lab
sodium measurements. It has columns: PATIENT_ID, VISIT_NUM, and
SODIUM.
DEMO is a dataset with one row per patient, with demographic data.
It has columns: PATIENT_ID, GENDER.
2015 Feb 24
2
intercalar elementos de vectores
Gracias, Carlos.
Habia pensado en algo similar usando sapply():
sapply(seq(1, ncol(vtmp), by = 2), function(i) c(rbind(as.character(vtmp[,
i]), as.character(vtmp[, i+1]))))
Dependiendo de la dimension de los datos, quizas mapply() sea mas eficiente
que sapply().
Saludos cordiales,
Jorge.-
2015-02-25 1:01 GMT+11:00 Carlos Ortega <cof en qualityexcellence.es>:
> Hola,
>
> Este
2008 Mar 06
2
Help with parsing a data file
Hi All,
I need to parse data from a file, example shown below. The first two lines
can be skipped, the third line contains the column names. The next 13 lines
can be skipped. The next line "1991" is a year value, with the following 13
values data for that year. The file then repeats this format with (year, 13
lines of data for that year). I would ideally like to end up with an
2019 Nov 30
1
Re: virt-df for KVM
On Sat, Nov 30, 2019 at 06:49:29PM +0800, zxs11289 wrote:
> I face a problem on KVM using virt-df。 I have two computer,they
> have installed tools for KVM. The computer(ip 15)has no virtual
> machine and computer(ip 33)has two virtual machines。on the
> computer(ip33), i run the command “virt-df” if on the computer(ip15),
> i run the command “virt-df --connect
2011 Jun 06
1
Lasso for k-subset regression
Dear R-users
I'm trying to use lasso in lars package for subset regression, I have a
large matrix of size 1000x100 and my aim is to select a subset k of the 100
variables.
Is there any way in lars to fix the number k (i.e. to select the best 10
variables)
library(lars)
aa=lars(X,Y,type="lasso",max.steps=200)
plot(aa,plottype="Cp")
aa$RSS
which.min(aa$RSS)
2011 Jul 12
7
FW: lasso regression
Hi,
I am trying to do a lasso regression using the lars package with the following data (see attached):
FastestTime
WinPercentage
PlacePercentage
ShowPercentage
BreakAverage
FinishAverage
Time7Average
Time3Average
Finish
116.90
0.14
0.14
0.29
4.43
3.29
117.56
117.77
5.00
116.23
0.29
0.43
0.14
6.14
2.14
116.84
116.80
2.00
116.41
0.00
0.14
0.29
5.71
3.71
117.24
2010 Dec 06
2
How to get lasso fit coefficient(given penalty tuning parameter \lambda) using lars package
Hi, all,
I am using the lars package for lasso estimate. So I get a lasso
fit first:
lassofit = lars(x,y,type ="lasso",normalize=T, intercept=T)
Then I want to get coefficient with respect to a certain value of \lambda
(the tuning parameter), I know lars has three mode options c("step",
"fraction", "norm"), but can I use the \lambda value instead
2013 May 04
2
Lasso Regression error
Hi all,
I have a data set containing variables LOSS, GDP, HPI and UE.
(I have attached it in case it is required).
Having renamed the variables as l,g,h and u, I wish to run a Lasso
Regression with l as the dependent variable and all the other 3 as the
independent variables.
data=read.table("data.txt", header=T)
l=data$LOSS
h=data$HPI
u=data$UE
g=data$GDP
matrix=data.frame(l,g,h,u)
2012 May 13
1
R package dependency issues when namespace is not attached
I have always assumed that having a package in the 'Depends' field
would automatically also?import?the namespace. However, it seems that
in R 2.15, dependencies do not become available until the package is
actually?attached?to the searchpath. Is this intended behavior?
The problem appears as follows: Suppose there is a package 'Child'
which?Depends, but does not explicitly
2007 Jun 12
1
LASSO coefficients for a specific s
Hello,
I have a question about the lars package. I am using this package to get the coefficients at a specific LASSO parameter s.
data(diabetes)
attach(diabetes)
object <- lars(x,y,type="lasso")
cvres<-cv.lars(x,y,K=10,fraction = seq(from = 0, to = 1, length = 100))
fits <- predict.lars(object, type="coefficients", s=0.1, mode="fraction")
Can I assign
2012 Jun 16
0
Selecting correlated predictors with LASSO
I'm using the package 'lars' in R with the following code:
> library(lars)
> set.seed(3)
> n <- 1000
> x1 <- rnorm(n)
> x2 <- x1+rnorm(n)*0.5
> x3 <- rnorm(n)
> x4 <- rnorm(n)
> x5 <- rexp(n)
> y <- 5*x1 + 4*x2 + 2*x3 + 7*x4 + rnorm(n)
> x <- cbind(x1,x2,x3,x4,x5)
> cor(cbind(y,x))
y x1 x2