[R] lme4 - Mixed Model question

2020-07-13 Thread Axel Urbiz
Dear List, I’d appreciate any guidance on the following. I’m using a mixed effects logistic regression model, to allow coefficients to vary by a group variable. However, my case is not typical in the sense that I need to specify a different set of covariates for each level of the group

Re: [R] "effects" package with "lme4"

2020-05-15 Thread Axel Urbiz
--- > John Fox, Professor Emeritus > McMaster University > Hamilton, Ontario, Canada > Web: socialsciences.mcmaster.ca/jfox/ > > > >> -Original Message- >> From: Axel Urbiz >> Sent: Friday, May 15, 2020 5:33 PM >> To: Fox, John ;

[R] "effects" package with "lme4"

2020-05-15 Thread Axel Urbiz
Hello John and others, I’d appreciate your help as I’m trying to plot the effect of predictor “Days” on Reaction by Subject. I’m only getting one plot in the example below. ### Start example library(lme4) library(splines) data("sleepstudy") fm1 <- lmer(Reaction ~ ns(Days, 3) + (ns(Days, 3) |

[R] Loop inside dplyr::mutate

2020-05-09 Thread Axel Urbiz
Hello, Is there a less verbose approach to obtaining the PC_i variables inside the mutate? library(tidyverse) sim_data <- data.frame(borrower_id = sort(rep(1:10, 20)), quarter = rep(1:20, 10), pd = runif(length(rep(1:20, 10 # conditional probs

[R] mgcv::bam with monotonic constraints

2019-01-13 Thread Axel Urbiz
Dear List, I need to fit a GAM to a large dataset (`mgcv::bam` does this), but ensuring that some covariates have a monotonic relation with the response. `mgcv::mono.con` with `mgcv::pcls` seem to do this, but only for `mgcv::gam` (not mgcv::bam)? I'd really appreciate any pointers! Regards,

[R] Spatial Clustering with spdep::skater

2018-07-07 Thread Axel Urbiz
Dear Experts, I’m working with spdep::skater to fit clusters to spatial data subject to contiguity constraints. This function fits clusters by edge removal from Minimum Spanning Trees. In this context, I’d appreciate any pointers on how to tune the number of clusters. What is a sensible

Re: [R] Add wrapper to Shiny in R package

2017-09-21 Thread Axel Urbiz
/ > /// > > > Van 14 tot en met 19 december 2017 verhuizen we uit onze vestiging in > Brussel naar het Herman Teirlinckgebouw op de site Thurn & Taxis. > Vanaf dan ben je welkom op het nieuwe adres: Havenlaan 88 bus

[R] Add wrapper to Shiny in R package

2017-09-21 Thread Axel Urbiz
Dear List, I'm trying to add a function that calls a Shiny App in my R package. The issue is that within my function, I'm creating objects that I'd like to pass to the app. For instance, from the example below, I'm getting "Error: object 'xs' not found". How can I pass "xs" explicitly to

[R] Shiny App inside R Package

2017-09-17 Thread Axel Urbiz
Dear List, I have a wrapper function that creates a Shiny App, as illustrated below. I'd like to include the function myApp() inside a package. I'd appreciate your guidance here, as I could not find good instructions on this online. myApp <- function(x) { require(shiny) shinyApp( ui =

[R] quote()/eval() question

2017-09-08 Thread Axel Urbiz
Dear list, For a reason it would take me long to explain, I need to do something along the lines of what's shown below -- i.e., create an object from dplyr::summarise, and then evaluate it on a data frame. I know I could directly do: df %>% dplyr::summarise(x1_mean = mean(x1)) but this is not

Re: [R] Can this be done in ggplot?

2017-04-15 Thread Axel Urbiz
lt;- factor(df$nv, levels = df$nv) ggplot(df, aes(x = nv , y = v, fill = f)) + geom_bar(position="dodge", stat = "identity") El 14/04/17 a las 10:08, Axel Urbiz escribi�: Hi, I need to bars to display in order based on the values of "v" within each group "

Re: [R] Can this be done in ggplot?

2017-04-15 Thread Axel Urbiz
<- df %>% arrange(g, desc(v)) > df$nv <- with(df, factor(paste(g,f))) > df$nv <- factor(df$nv, levels = df$nv) > > ggplot(df, aes(x = nv , y = v, fill = f)) + > geom_bar(position="dodge", stat = "identity") > > > El 14/04/17 a l

[R] Can this be done in ggplot?

2017-04-14 Thread Axel Urbiz
Hi, I need to bars to display in order based on the values of "v" within each group "g". Is this possible? library(ggplot2) set.seed(1) df <- expand.grid(g = 1:4, f = factor(c("a", "b", "c"))) df <- df[-1, ] # some factors are not present in certain groups df$v <- runif(nrow(df)) ggplot(df,

[R] Combining grid::grid.raster plots

2017-04-10 Thread Axel Urbiz
Dear Group, I'd like to combine many grid::grid.raster plots into a single layout. Here's my attempt, which does not work (i.e., does not combine the 9 images into a single plot layout). require(grid) random_image <- function() { r <- matrix(sample(1:255, 32 * 32, replace = TRUE), nrow =

[R] Deploying R on the cloud - Help Please

2017-03-31 Thread Axel Urbiz
Hello, I work for a large organization who is looking to productionize (deploy) models built in R on the cloud. Currently, we were looking into IBM Bluemix, but I’ve been told only Python is supported for model deployment. I’d appreciate if anyone can point me to the right direction here in

[R] Extending sparklyr

2016-10-09 Thread Axel Urbiz
Hi All, Just started to experiment with "sparklyr" and already loving it. I'm trying to build an extension by constructing an R wrapper to Spark's Gaussian Mixtures. My attempt is below, and so is the error message. Not sure if this is possible to do, and if so, what is wrong with my code. Any

[R] Defining contrasts within function

2016-05-23 Thread Axel Urbiz
Dear All, I'd like to change the options("contrasts") within a function, such that "identity" contrasts are created for unordered factors. I'm following the idea shown below, which works fine. However, when I include these functions in a package (with `contr` being exported, but `contr_identity`

[R] TensorFlow in R

2016-04-01 Thread Axel Urbiz
Hi All, I didn't have much success through my Google search in finding any active R-related projects to create a wrapper around TensorFlow in R. Anyone know if this is on the go? Thanks, Axel. [[alternative HTML version deleted]] __

[R] Sorting in trees problem

2016-02-24 Thread Axel Urbiz
Hello, As decision trees require sorting the variable used for splitting a given node, I'm trying to avoid having this recurrent sorting by only sorting all numeric variable first (and only once). My attempt in doing this is shown in "Solution 2" below, but although I get the desired result I

[R] model.matrix behaviour

2016-01-07 Thread Axel Urbiz
Hello, I apologize my prior email was sent in html. It is not very clear to me from the model.matrix documentation, why simply changing the order of terms in the formula may give a different design matrix. Please note I’m purposely not including main effects in the model formulae.

Re: [R] Extract Standard Errors of Model Coefficients

2015-12-29 Thread Axel Urbiz
1263650 0.01160511 > > You may have a reason to use glm.fit in preference to glm, but I'm not sure > why you'd want to do that. > > I hope this helps, > John > > --- > John Fox, Professor > McMaster University > Hamilton,

[R] Extract Standard Errors of Model Coefficients

2015-12-29 Thread Axel Urbiz
Hello, Is it possible to extract or compute the standard errors of model coefficients from a glm.fit object? This can be easily done from a fitted glm object, but I need glm.fit. set.seed(1) n <- 100 x <- rnorm(n) y1 <- rnorm(n) y2 <- rbinom(n, 1, .25) M1 <- glm (y1 ~ x) M2 <- glm.fit(x =

[R] Returning a factor from vapply

2015-11-25 Thread Axel Urbiz
Hello, I would like to return a factor from vapply, which looks it cannot be done directly since a factor is typeof() numeric. So I’m not sure if the solution below is the standard approach to handle this. My concern is that the factor levels are mixed up in the results (as shown in the last

[R] rank/sort problem

2015-11-21 Thread Axel Urbiz
Hello, I would like to sort the df below, such that it sorts y1 in decreasing order for tt == 1 and in increasing order for tt == 0. My solution is below, but curious if there might be something better (meaning faster in this case). Actually, if instead if implicitly sorting, I could add a

[R] Help with dplyr

2015-11-05 Thread Axel Urbiz
Hello, Is there a way to avoid the warning below in dplyr. I’m performing an operation within groups, and the warning says that the factors created from each group do not have the same levels, and so it coerces the factor to character. I’m using this inside a package I’m developing. I’d

Re: [R] Help with dplyr

2015-11-05 Thread Axel Urbiz
The . . Go >>> Live... >>>> DCN:<jdnew...@dcn.davis.ca.us>Basics: ##.#. ##.#. Live >>> Go... >>>> Live: OO#.. Dead: OO#.. >>> Playing >>>

[R] dplyr instead of plyr: Help

2015-11-02 Thread Axel Urbiz
Sorry, this is *related* to a recent post, but not the same. I'd appreciate your help in getting the same results with the two methods below (the first using plyr and the second using dplyr. The former works, but not the latter.) ### Sample data set.seed(4) df <- data.frame(pred = rnorm(100),

Re: [R] User-defined functions in dplyr

2015-11-02 Thread Axel Urbiz
arise_impl", PACKAGE = "dplyr", df, dots) > However it is clear that the fault is in your function, which is expecting a > data.frame x with a column called pred but gets pred itself. Change x to > xpred > in the argument list and x$pred to xpred in the body of the functio

[R] dplyr instead of plyr: Help

2015-11-02 Thread Axel Urbiz
Sorry, this is *related* to a recent post, but not the same. I'd appreciate your help in getting the same results with the two methods below (the first using plyr and the second using dplyr. The former works, but not the latter.) ### Sample data set.seed(4)df <- data.frame(pred = rnorm(100), y =

Re: [R] User-defined functions in dplyr

2015-11-02 Thread Axel Urbiz
X > 6 C Z NA > > levels(.Last.value$fv) > [1] "X" > > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com <http://tibco.com/> > On Mon, Nov 2, 2015 at 5:38 PM, Axel Urbiz <axel.ur...@gmail.com > <mailto:axel.ur...

Re: [R] User-defined functions in dplyr

2015-10-30 Thread Axel Urbiz
Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from m

[R] User-defined functions in dplyr

2015-10-29 Thread Axel Urbiz
Hello, Sorry, resending this question as the prior was not sent properly. I’m using the plyr package below to add a variable named "bin" to my original data frame "df" with the user-defined function "create_bins". I'd like to get similar results using dplyr instead, but failing to do so.

[R] User-defined functions in dplyr

2015-10-29 Thread Axel Urbiz
Hello, I’m using the plyr package to add a variable named "bin" to my original data frame "df" with a user-defined function "create_bins". I'd like to get similar results using dplyr instead, but failing to do so. set.seed(4)df <- data.frame(pred = rnorm(100), models = gl(2, 50, 100, labels =

[R] Variable names conflict

2015-10-15 Thread Axel Urbiz
Hello, I have a variable named 'x' defined inside a function, which may conflict with a variable name supplied in the argument to the function. What is the best practice to avoid this conflict? foo <- function(df) { x <- df[, 1, drop = FALSE] dfOut <- data.frame(df, x) dfOut } Data <-

[R] H2O Package - Error Messages

2015-08-08 Thread Axel Urbiz
Hello, I've been experimenting with the H2O package, which seems to be a very interesting and promising project. I'm getting a few error messages through using h2o.deeplearning (which I guess it must be something I'm doing wrong). Here is a reproducible example of errors using the n_folds

Re: [R] Error in local package install

2015-06-16 Thread Axel Urbiz
Thanks Uwe. Actually, the problem persists in R-3.2.1. If it helps, the .zip file is here: http://win-builder.r-project.org/yC8eUu09w3Ui/ Thank you, Axel. On Mon, Jun 15, 2015 at 5:41 PM, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 15.06.2015 22:32, Axel Urbiz wrote: Hello

Re: [R] Error in local package install

2015-06-16 Thread Axel Urbiz
...@statistik.tu-dortmund.de wrote: On 16.06.2015 15:16, Axel Urbiz wrote: Thanks Uwe. Actually, the problem persists in R-3.2.1. If it helps, the .zip file is here: http://win-builder.r-project.org/yC8eUu09w3Ui/ Works for me, but your error message is: cannot open compressed file 'mypackage

[R] Error in local package install

2015-06-15 Thread Axel Urbiz
Hello, I've built a windows binary package from my Mac using the help from this site: http://win-builder.r-project.org As expected, I got back the file mypackage.zip. Also, the logs show no errors. Now, when I try to install on windows using the GUI install package(s) from local zip files, I

[R] geom_errorbar() issue in ggplot2

2015-04-23 Thread Axel Urbiz
Hello, I'm getting a warning message from the reproducible example below. Why would geom_errorbar() remove 2 cases in this case? Both upper and lower limits of the error bar contain var1 and are within the axis limits. df - data.frame(var1 = seq(0, 1, 0.1), var2 = seq(0, 1, 0.1)) df$ll -

Re: [R] geom_errorbar() issue in ggplot2

2015-04-23 Thread Axel Urbiz
answer can be extracted from a given body of data. ~ John Tukey 2015-04-23 12:06 GMT+02:00 Axel Urbiz axel.ur...@gmail.com: Hello, I'm getting a warning message from the reproducible example below. Why would geom_errorbar() remove 2 cases in this case? Both upper and lower limits

[R] Installing R on Linux Red Hat Server

2015-03-12 Thread Axel Urbiz
Hello, My apologies if this is not the right place to post this question. I need to get R installed on a Linux Red Hat server. I have very limited exposure to R and would appreciate some basic guidance if you could point me to resources describing the process, requirements, etc. Thank you in

[R] Error in help files connection

2015-01-29 Thread Axel Urbiz
Hello, I'm building a package on Mac OS. The build/check/install goes all ok. Also, the package gets loaded properly with library(my_package). However, when I call the help file for a given function in the package -- i.e., ?my_function, I get the following error: Error in gzfile(file, rb) :

[R] Rubik cube-like plot in R

2014-10-25 Thread Axel Urbiz
Hi there, I need to create a Rubik cube plot in R, except that I don't need the face colours (all faces with the same colour is fine). I'd appreciate your guidance in terms of what graphic tool would be best for this purpose. Best, Axel. [[alternative HTML version deleted]]

[R] Question about searchTwitter{twitteR}

2014-09-07 Thread Axel Urbiz
Hello, The function searchTwitter() with the arguments supplied as below would give me a different number of results on different days I run this code. Maybe it is my lack of understanding about what the date arguments are supposed to do in this function, but I would think I should be getting the

Re: [R] Predictions from coxph or cph objects

2014-07-06 Thread Axel Urbiz
to medians and quantiles. Göran Broström On 2014-07-06 06:17, David Winsemius wrote: On Jul 5, 2014, at 9:12 PM, David Winsemius wrote: On Jul 5, 2014, at 12:43 PM, Axel Urbiz wrote: Thank you David. It is my understanding that using survfirsurvit below I get the median predicted

[R] Predictions from coxph or cph objects

2014-07-05 Thread Axel Urbiz
Dear R users, My apologies for the simple question, as I'm starting to learn the concepts behind the Cox PH model. I was just experimenting with the survival and rms packages for this. I'm simply trying to obtain the expected survival time (as opposed to the probability of survival at a given

Re: [R] Predictions from coxph or cph objects

2014-07-05 Thread Axel Urbiz
+ ph.ecog, lung) pred - survfit(fit, newdata=lung) head(pred) Thanks again, Axel. On Sat, Jul 5, 2014 at 1:54 PM, David Winsemius dwinsem...@comcast.net wrote: On Jul 5, 2014, at 5:28 AM, Axel Urbiz wrote: Dear R users, My apologies for the simple question, as I'm starting to learn

[R] knitr - Highlight code/output

2014-05-03 Thread Axel Urbiz
Hello, I find situations where some segments of the code are displayed in the output but not entirely highlighted. I guess there should be a way to fix this, but I could't find it in the options. Here's an example with knitr/LaTex. \documentclass{article} \begin{document} \section{Example 1}

Re: [R] Sweave files into LaTex

2014-04-07 Thread Axel Urbiz
have more than just a few code chunks, you should do your work in master.Rnw and produce master.tex from that using either sweave() or knitr() -M On 4/4/2014 7:10 PM, Axel Urbiz wrote: Hi, I'm writing a thesis in Latex (say master.tex). I'd like to include R code/results from an .Rwd

[R] Sweave files into LaTex

2014-04-04 Thread Axel Urbiz
Hi, I'm writing a thesis in Latex (say master.tex). I'd like to include R code/results from an .Rwd file. I've naively tried: 1) Add ONLY the code below in Rcode.Rnw file: \section{Exploratory data analysis} eval=TRUE, echo=FALSE= library(ggplot2) data(diamonds) head(diamonds) @ 2) Then, in

[R] Package dependencies in building R packages

2013-12-30 Thread Axel Urbiz
Dear users, My package {foo} depends on a function miscFUN which is on package {foo_depend}. This last package also depends on other packages, say {A, B, C}, but miscFUN is not dependent on A, B, C (only on foo_depend). In my package {foo}, is there a way to only have it depend on the function

Re: [R] Package dependencies in building R packages

2013-12-30 Thread Axel Urbiz
, Dec 30, 2013 at 7:51 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 13-12-30 1:24 PM, Axel Urbiz wrote: Dear users, My package {foo} depends on a function miscFUN which is on package {foo_depend}. This last package also depends on other packages, say {A, B, C}, but miscFUN

[R] Help with vapply() loop

2013-10-02 Thread Axel Urbiz
Hello, Although the example below doesn't necessary make any sense from a statistical perspective, it is just a close enough example to hopefully get your help upon. For my purpose, I'm particularly interested to know if there is a way to replace the results from the vapply() function below by a

[R] Permutation Test on Interactions {coin}

2013-09-23 Thread Axel Urbiz
Dear List, I'm interested in performing a permutation test on the interaction between a binary treatment indicator and a covariate (either continuous or categorical). I'm interested in the p-value of the interaction effect from a permutation test, and I'm using the coin package for that purpose.

[R] glmnet on Autopilot

2013-07-17 Thread Axel Urbiz
Dear List, I'm running simulations using the glmnet package. I need to use an 'automated' method for model selection at each iteration of the simulation. The cv.glmnet function in the same package is handy for that purpose. However, in my simulation I have p N, and in some cases the selected

[R] Constrained Optimization in R (alabama)

2013-02-10 Thread Axel Urbiz
Dear List, I'm trying to solve this simple optimization problem in R. The parameters are the exponents to the matrix mm. The constraints specify that each row of the parameter matrix should sum to 1 and their product to 0. I don't understand why the constraints are not satisfied at the solution.

[R] Optimization Problem in R

2013-02-09 Thread Axel Urbiz
Dear List, I'm new in R. I'm trying to solve a simple constrained optimization problem. Essentially, let's say I have a matrix as in the object 'mm' inside the function below. My objective function should have a matrix of parameters, one parameter for each element 'mm' (4 in this case). The

[R] Problem with ggmap

2012-12-07 Thread Axel Urbiz
Dear List, I run the code below on my Mac and works fine. On Win 7 64-bit, I’m getting the error message at the bottom.In both cases, I’m using R 2.15.2. Any clue? v1 = c(43.6, 43.8, 44.2); # Latitude for added points v2 = c(-80, -79.5, -79.0); # Longitude for added points

[R] Credit Scoring in R - Weight of Evidence

2012-10-20 Thread Axel Urbiz
Dear List, I couldn't find any package that performs the weight of evidence of predictors (a transformation usually performed in credit scoring applications). Is there any that you know? Thanks, Axel. [[alternative HTML version deleted]] __

Re: [R] Complex sort problem

2012-05-18 Thread Axel Urbiz
it with respect to potentially any variable. Thanks again, Axel. On Thu, May 17, 2012 at 1:43 PM, Petr Savicky savi...@cs.cas.cz wrote: On Thu, May 17, 2012 at 06:45:52AM -0400, Axel Urbiz wrote: Dear List, Is there a way I can sort a sample based on a sort index constructed from the data from

Re: [R] Complex sort problem

2012-05-18 Thread Axel Urbiz
[, var1][match(sort_matrix[, var1], b.ind)] #this does not work, and if it did would be slow Thanks again, Axel. On Fri, May 18, 2012 at 9:50 AM, David Winsemius dwinsem...@comcast.netwrote: On May 18, 2012, at 6:37 AM, Axel Urbiz wrote: Would I be able to accomplish the same if x.sample

[R] Complex sort problem

2012-05-17 Thread Axel Urbiz
Dear List, Is there a way I can sort a sample based on a sort index constructed from the data from which the sample is taken? Basically, I need to take 'many' samples from the same source data and sort them. This can be very time consuming for long vectors. Is there any way I can sort the data

[R] Last element of a vector by group

2012-05-15 Thread Axel Urbiz
Dear List, How can I get a logical vector as shown by a.ord.last below (i.e., it is FALSE whenever there are subsequent equal values of an ordered vector and FALSE otherwise)? a - c(1,1,2,1,3,4,3,5,6) a.ord - a[order(a)] a.ord a.ord.last - c(F, F, T, T, F, T, T, T, T) Thanks for any help

[R] Issue with message()

2012-04-22 Thread Axel Urbiz
Dear List, I built a package under both Mac and Win 7 (both on R 2.12.0) . One of the functions in the package is set up to print a status message using the code below: if (verbose) if ((i %% 10) == 0 i ntree) message( , i, out of, ntree, trees so far...) This works perfectly on the

[R] DESCRIPTION FILE in R Manuals

2012-04-06 Thread Axel Urbiz
Dear List, In building a package on a Mac, all the steps performed (build, check, install) seem to be working fine (no warning messages or errors). The manual for the package is created and everything looks good except for the fact that the header of the document is not showing the info on the

[R] Help with operation on list of matrices

2012-03-14 Thread Axel Urbiz
I'll appreciate your help on this. I have values stored in a list as in mylist below. I need to sum the values over all elements of the list aggregated by the names of the matrices. mylist - list(matrix(c(0.2, 0.4), 1, 2, dimnames = list(NULL, c(1, 2))), matrix(c(0.1, 0.5), 1,

[R] Conditional cumulative sum

2012-01-26 Thread Axel Urbiz
Dear List, I'll appreciate your help on this. I'm trying to create a variable as in cumsum_y.cond1 below, which should compute the cumulative sum of y conditional on the value of cond==1. set.seed(1) d - data.frame(y= sample(c(0,1), 10, replace= T), cond= sample(c(0,1), 10,

Re: [R] Random Forests in R

2011-12-02 Thread Axel Urbiz
Of Peter Langfelder Sent: Thursday, December 01, 2011 12:33 AM To: Axel Urbiz Cc: R-help@r-project.org Subject: Re: [R] Random Forests in R On Wed, Nov 30, 2011 at 7:48 PM, Axel Urbiz axel.ur...@gmail.com wrote: I understand the original implementation of Random Forest was done

[R] Random Forests in R

2011-11-30 Thread Axel Urbiz
I understand the original implementation of Random Forest was done in Fortran code. In the source files of the R implementation there is a note C wrapper for random forests: get input from R and drive the Fortran routines.. I'm far from an expert on this...does that mean that the implementation

[R] R Interface to C / C++‏

2011-11-29 Thread Axel Urbiz
Dear List, I’d like to modify the R rpart package source code to add a new split criterion. I’m familiar with R, but not at all with C or C++. I understand C and C++ are quite different, and I don’t have the time to learn both, so my questions are (i) which one should I learn for the specific

[R] Question about .Fortran in glmnet package

2011-10-26 Thread Axel Urbiz
Hi, My apologies for asking this question, but could not find the answer elsewhere. I understand the glmnet package uses Fortran code. For example, the lognet.R file includes the lines of code shown below. But how can I see the Fortran code that is being referenced in the code below? Is that

[R] Problem installing tweetR on Ubuntu

2011-10-19 Thread Axel Urbiz
Dear List, When I try to install tweetR on Ubuntu, I get the error message below. It is a problem with the dependency RCurl. This package is not available for Windows on CRAN, but I would assume that I should have no problem with linux. Any help is much appreciated. R version: 2.12.1 Platform:

[R] Question about Natural Splines (ns function)

2011-09-06 Thread Axel Urbiz
Hi - How can I 'manually' reproduce the results in 'pred1' below? My attempt is pred_manual, but is not correct. Any help is much appreciated. library(splines) set.seed(12345) y - rgamma(1000, shape =0.5) age - rnorm(1000, 45, 10) glm1 - glm(y ~ ns(age, 4), family=Gamma(link=log)) dd -

[R] Source Code glm() question

2011-08-10 Thread Axel Urbiz
Dear List, I'm fairly new in R. I'd like to see how glm() uses the argument family in fitting a model. Specifically, I'd like to see how a glm with a gamma family is fitted. Thanks for any help, Axel. [[alternative HTML version deleted]] __

Re: [R] Help with extending glmnet

2011-07-31 Thread Axel Urbiz
interested in learning the 'know how' from your first question. Thanks for this, Axel. On Sat, Jul 30, 2011 at 7:46 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 11-07-30 5:55 PM, Axel Urbiz wrote: Dear List, I'd like to extend the glmnet package to account for one additional distribution

[R] Help with extending glmnet

2011-07-30 Thread Axel Urbiz
Dear List, I'd like to extend the glmnet package to account for one additional distribution: the Tweedie (compound of Poisson and Gamma). Could you please point me on how should I do this? Thanks for any help, Axel. [[alternative HTML version deleted]]

[R] Problem with read.shape in maptools

2011-07-23 Thread Axel Urbiz
Hi, I'd like to read a shapefile into a Map object. This is exactly what read.shape{maptools} is suppoed to do, according to the documentation I found in the link below. However, this doesn't seem to work library(maptools)x - read.shape(system.file(shapes/sids.shp, package=maptools)[1])Error:

[R] SpatialPolygonsDataFrame to map conversion?

2011-07-21 Thread Axel Urbiz
Dear list, I'd like to use the function smooth.map{maps} to smooth out aggregated spatial data. The first argument to this function must be a map object. I have a shape file which I read with readShapeSpatial{maptools} and I got an object of class SpatialPolygonsDataFrame. Is it possible to

[R] Adding dash-lines in R tables

2011-05-22 Thread Axel Urbiz
is it possible to add dash lines to tables or matrices when they are printed? An example of what I'm looking for is this: library(Design) y - sample(c(0,1),100, replace = TRUE) x - rnorm(100) summary(y ~ x) Thanks, Axel. [[alternative HTML version deleted]]

[R] Need expert help with model.matrix

2011-05-18 Thread Axel Urbiz
Dear experts: Is it possible to create a new function based on stats:::model.matrix.default so that an alternative factor coding is used when the function is called instead of the default factor coding? Basically, I'd like to reproduce the results in 'mat' below, without having to explicitly

[R] Help with options(contrasts)

2011-05-09 Thread Axel Urbiz
Dear list, Is it possible to specify a contrast in options() that would create an identity matrix for each factor in the model matrix? For example, for each factor in 'dd' below, I can create an identity matrix using contrasts = FALSE. Is it possible to set this in options(), so when I create a

[R] Orthoblique rotation on eigenvectors (SAS VARCLUS)

2011-04-09 Thread Axel Urbiz
Hi All, I'd like to build a package for the community that replicates the output produced by SAS proc varclus. According to the SAS documentation, the first few steps are: 1. Find the first two principal components. 2. Perform an orthoblique rotation (quartimax rotation) on eigenvectors. 3.

[R] Help in sub-setting a List

2011-04-04 Thread Axel Urbiz
Dear R users, Let's say I have a list with components being 'm' matrices (as exemplified in the mylist object below). Now, I'd like to subset this list based on an index vector, which will partition each matrix 'm' in 2 sub-matrices. My questions are: 1. Is there an elegant way to have the

[R] Help in splitting ists into sub-lists

2011-04-03 Thread Axel Urbiz
Dear List, Let's say I have a list whose components are 2 matrices (as exemplified in the mylist object below). I'd like to create a list with components being 4 matrices based on an logical index vector. is there a way to simplify what I'm doing to obtain the results in mylist2? I'd like

[R] Help: creating owin{spatstat} objects from GIS data

2011-03-30 Thread Axel Urbiz
Dear R list, I'm trying to create an object of class owin (observation window) in the package spatstat from GIS mapping data. Here's an example of my problem. Everything goes well until the last line of code. I get the error message shown at the bottom: library(spatstat) library(sp)

[R] Help with Time Series Plot‏

2011-03-17 Thread Axel Urbiz
Dear List, This is an embarrassing question, but I can seem to make this work…How do I change the font size on the xlab and on the numbers shown in the x-axis on the time series plot below. The arguments cex.lab and cex.axis do not seem to be 'passing' to the plot function. plot(ts(rnorm(100),

[R] Reproducibility issue in gbm (32 vs 64 bit)

2011-02-25 Thread Axel Urbiz
Dear List, The gbm package on Win 7 produces different results for the relative importance of input variables in R 32-bit relative to R 64-bit. Any idea why? Any idea which one is correct? Based on this example, it looks like the relative importance of 2 perfectly correlated predictors is

[R] Predictions with missing inputs

2011-02-11 Thread Axel Urbiz
Dear users, I'll appreciate your help with this (hopefully) simple problem. I have a model object which was fitted to inputs X1, X2, X3. Now, I'd like to use this object to make predictions on a new data set where only X1 and X2 are available (just use the estimated coefficients for these

[R] Predictions with 'missing' variables

2011-01-25 Thread Axel Urbiz
Dear List, I think I'm going crazy here...can anyone explain why do I get the same predictions in train and test data sets below when the second has a missing input? y - rnorm(1000) x1 - rnorm(1000) x2 - rnorm(1000) train - data.frame(y,x1,x2) test - data.frame(x1) myfit - glm(y ~ x1 + x2,

[R] Question about glmnet

2010-10-21 Thread Axel Urbiz
Hi, Is it possible to include factor variables as model inputs using this package? I'm quite sure it is not possible, but would like to double check. Thanks, Axel. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] Creating functions of many arguments

2010-07-15 Thread Axel Urbiz
Dear users, My apologies for the simple question. I'd like to create a function where the number of arguments is as big as the size of my data set. Supose I have n observations in my data, how can I write a function like fun - function (x1,x2,,xn) {x1*x2*...*xn} Thanks in advance for

[R] R on Linux - a primer

2010-03-14 Thread Axel Urbiz
Hi, I'm looking to move from Windows into a 64-bit Linux environment. Which is the best Linux Flavor to use within R? To install R on this environment, do I need to do any compiling? Thanks all! Axel. [[alternative HTML version deleted]] __

[R] R on 64-Bit…

2010-02-21 Thread Axel Urbiz
Dear R users, I know this issue came up in the list several times. I’m currently running R on 32-bit on Windows and due to memory limitation problems would like to move to a 64-bit environment. I’m exploring my options and would appreciate your expertise: 1) Windows 64-bit: Prof. Brian

[R] Help using leaps package

2009-11-10 Thread Axel Urbiz
Dear R users, I'm new in R and couldn't find the solution to this in the postings. I want to be able to use the leaps package to perform an exhaustive regression. Most of my variables are categorical with many levels. I'd like to restrict the candidate subsets to either all levels included or all

[R] Exhaustive search in leaps - Help Please

2009-11-07 Thread Axel Urbiz
Dear R users, I'm new in R and couldn't find the solution to this in the postings. I want to be able to use the leaps package to perform an exhaustive regression. Most of my variables are categorical with many levels. I'd like to restrict the candidate subsets to either all levels included or all

[R] Text Mining in R

2009-10-10 Thread Axel Urbiz
Dear R users, I'm new in Text Mining applications and just started to look into the tm package. If anyone of you has experience with this package, I'll appreciate if you could share your thoughts around it. Also what's the best way to store large amounts of text data on limited RAM when using

[R] Penalized Logistic Regression - Query

2009-09-24 Thread Axel Urbiz
Dear R users, Is there any package that I could use to perform Penalized Logistic Regression (i.e. Ridge/Lasso regularization) including also an offset term in the model (i.e. a variable with a known coefficient of 1 rather than an estimated coefficient)? I couldn't find any package that would

[R] Poisson Regression - Query

2009-09-19 Thread Axel Urbiz
Hi All, My dependent variable is a ratio that takes a value of 0 (zero) for 95% of the observations and positive non-integer values for the other 5%. What model would be appropriate? I'm thinking of fitting a GLM with a Poisson ~. Now, becuase it takes non-integer values, using the glm function

[R] Help with Loop Please!

2009-09-13 Thread Axel Urbiz
Hi, I’d like to fit one GLM model for each possible combination of inputs (i.e. exhaustive search). The package leaps can help me to generate all possible variable subsets, but I’ll appreciate your guidance as of how to generate one model for each of those possible subsets. I’m new in R! Thanks

[R] Weighted Analysis in Data Mining

2009-07-11 Thread Axel Urbiz
Dear R community, I’m new in R (coming from SAS). If possible, I’d like to know your thoughts regarding the following. I’m working on a regression problem, where my dependent variable is a ratio of two variables (i.e. dep.var=A/B). The variable A takes a value of zero for the vast majority of

  1   2   >