R is an open source programming language and software environment for statistical computing and graphics.
-4
votes
0answers
14 views
Choosing highest number in vector and knowing its position in R [migrated]
I have a vector in R:
y=c(-29.900900, 5.728916, 35.234331, 11.854811, 61.309519, 50.432798, -27.654741, 21.413622, -10.805339, -37.504199)
I would like to ...
3
votes
5answers
438 views
Generate three random numbers that sum to 1 in R
I would like to generate three random numbers and then standardize them so that they add up to 1.
I would like to repeat this procedure so that in the long run the mode is .33 for each number.
3
votes
0answers
36 views
How to build a model where variance depends on covariate?
I have what I believe is a very simple problem for anyone used to modelling with unequal variances (which I am unfortunately not). I have a dependent variable "totrich" which I want to model as a ...
2
votes
1answer
51 views
Iterative proportional fitting in R
The mission
I am trying to find a way to do Iterative Proportional Fitting in R. The logic of the procedure is like this: one has a table with e.g. sample distribution of some variables. Let us say ...
0
votes
1answer
44 views
Fit of a normal distribution to a one-dimensional dataset in R
I've got a set of (continuous) values from a measurement, where each object should be either positive or negative, and I know that the values of the "negative" objects should be approximately normally ...
0
votes
0answers
24 views
1
vote
1answer
72 views
First steps learning to predict financial timeseries using machine learning
I am trying to get a grasp on how to use machine learning to predict financial timeseries 1 or more steps into the future.
I have a financial timeseries with some descriptive data and I would like to ...
0
votes
1answer
51 views
Randomizing variables to get the best combination for high R-squared values in R
I've been spending quite some time to figure out how I can get the best R squared value from randomization of some values in a linear regression equation. I have allele frequency data and 14 ...
1
vote
2answers
122 views
Forecast total for a year given monthly time series
I have a monthly time series (for 2009-2012 non-stationary, with seasonality). I can use ARIMA (or ETS) to obtain point and interval forecasts for each month of 2013, but I am interested in ...
1
vote
1answer
46 views
Multiple Linear Regression Simulation
I'm new to the R language. I would like to know how to simulate from a multiple linear regression model that fulfills all four assumptions of the regression.
0
votes
1answer
35 views
Exogeneous regressors in auto.arima and using them in forecast function in R
I'm trying to forecast a seasonal time series based on its historical values, and also two more time series (that are seasonal themselves.)
I'm trying to use an auto.arima, and I'm going to input ...
1
vote
1answer
37 views
Expected peak to trough calculation
I am having trouble coding up in R equation 3.1 in the following paper: http://www.intelligenthedgefundinvesting.com/pubs/rb-cb.pdf
My function:
...
0
votes
1answer
35 views
Weighted multiple regression in R with prespecified weights
I would like to run a regression of the following form:
Y ~ B1*predictor1 + B2*predictor2 + B3*predictor3
I would like to specify ...
2
votes
1answer
89 views
How to forecast hourly data in R
I have hourly login data for a web site. Certain hours of the day for example between 09:00 and 12:00, there are heavy traffic on the site. I would like to forecast the hourly data for about one year.
...
2
votes
0answers
25 views
Generate predictors with fixed predictive validity in R
Let's say I have a dataset:
x=rnorm(1000, mean=0, sd=10)
I would like to create five variables (a,b,c,d,e) that I can use to ...
1
vote
1answer
28 views
Separate specifications for p and n in a binomial GLM
For a binomial GLM, both the probability and the number of trials are important for each data entry. Using the glm fucntion in R, how do I specify them separately ...
0
votes
1answer
40 views
Basic questions concerning the interpretation of results from summary(lm(…~…)) in R [duplicate]
set.seed(11)
a = runif (12)
b = rep(c(1,2,3),4)
summary(lm(a~b))$coeff
summary(lm(a~b-1))$coeff
What does a p.value for the intercept means ?
What differences ...
1
vote
0answers
9 views
Easy way to combine mean and sd in one table using tapply? [migrated]
In R's tapply function, is there an easy way to output multiple functions combined (e.g. mean and ...
13
votes
4answers
481 views
Why and when create a R package?
I understand this question is quite a broad one, but I wonder what should be the decisive points in deciding to create (or not) a new package for R. To be more specific, I would add that the question ...
0
votes
0answers
35 views
Identification of Integer valued ARIMA process, INARIMA
I was wondering if there is any tools like R that can be used to identify the Integer valued ARIMA process? I know that using forecast package in R we can identify the ARIMA process , is there any ...
0
votes
0answers
21 views
Strategy for building best fit multiple regression model with time lagged variables
I am building a multiple regression model - wrapped in a function - with one dependent variable and a dozen independent variables. The reason why I am building a function is that I need to do this ...
0
votes
0answers
16 views
How to embed a dictionary into R glm formula? [migrated]
I'm trying to predict a class (its binary classification) of a tweet, based on those users, who did a retweet. And I want to include into formula not the count of retweets, but every user who did it. ...
0
votes
0answers
40 views
lm to lmer function tweaking
I have stolen and modified a snippet of code found off the internet from (http://www.r-bloggers.com/aic-bic-vs-crossvalidation/) which graphically depicts AIC and BIC values for different polynomial ...
0
votes
0answers
34 views
How to create a new vector from grouped data in R? [migrated]
Possible duplicate on SO: Computing a new variable using conditions of an existing data frame
I am trying to create a vector (e.g. z) from the group means. The vector will have a length equal to the ...
0
votes
1answer
30 views
ncvTest from R and interpretation
I have done a ncvTest, but I am not really sure how to interpret this properly. I look documentation and examples online but was not able to find anything that clearly explains about ncvTest.
Here ...
1
vote
0answers
19 views
Simulate LMM data with specific error values using R
I have a need to simulate data in R using the following:
Simulate data for 5 (or more) subjects, indexed by $i$, $(i=1,~...,~5)$ with $6$ observations per subject indexed by $t$ $(t=1,~2,~...,~6)$. ...
0
votes
0answers
20 views
Different results from SAS PROC MIXED procedure and R lme function
I have 3(treatment)x3(period)x6(sequence) crossover design data. I have used SAS PROC MIXED procedure and I got the results with following code:
...
0
votes
0answers
8 views
Debugging simple R code [migrated]
For a homework assignment I'm constructing a simple code. R keeps returning that a x0 is missing in evaluating p2. I can't ...
2
votes
0answers
36 views
Clustering longitudinal (trajectory) data
I am hoping to implement an unsupervised technique that identifies distinct clusters of individuals based on longitudinal data: 100 continuous or categorical variables measured at different ages.
A ...
4
votes
1answer
155 views
Fixed vs Random Effects
I have very recently started learning about Generalised Linear Mixed Models and was using R to explore what difference it makes to treat group membership as either fixed or random effect. In ...
0
votes
0answers
15 views
How to combine different barplot in R? [migrated]
I am a new R user.
I have a difficult time figuring out how to combine different barplot into one graph.
For example,
Suppose, the top five of professions in China, are, government employees, ...
0
votes
0answers
16 views
How do I label the rows and columns in a diagonal matrix? [migrated]
i'm creating a diagonal matrix of variances in R, thus:
D <- diag( data $ Variances, length(data $ Variances), length(data $ Variances))
Does anyone know how to add row and column labels? The ...
0
votes
1answer
52 views
Stepwise introduction of predictors to mixed-effects models
As the title says, what I'd like to do is stepwise introduction of predictor variables to a mixed-effects model. I'm going to first say what I'd be doing if it were stepwise linear regression, just to ...
2
votes
1answer
37 views
Computing by hand the optimal threshold value for a biomarker using the Youden Index
I have an empirical estimate of a ROC curve, that is, a plot of the sensitivity versus 1-specificity over all possible cut-off values of the marker.
Based on an empirical ROC curve, I would like to ...
2
votes
3answers
78 views
Which glm algorithm to use when predictors are numerical as well as categorical?
I just need a direction on which regression algorithm (preferably glm or similar) algorithm to use when the predictor variables are a mix of numerical and categorical variables. The output is ...
1
vote
1answer
59 views
Use of two-sample Kolmogorov-Smirnov test to evaluate similarities between two different distributions
$X_1, X_2, \dots X_n$ and $Y_1, Y_2, \dots Y_n; n = 1000$ are two samples of physical quantities coming from the application of two different mathematical models to some independent and identically ...
-1
votes
1answer
36 views
4
votes
2answers
142 views
Data visualization of average and standard deviation over a small time series
I am trying to find the best way to visualize the following data:
I have values for 3 different times/dates, each time/date has the same 20 species. For each species I have the average height and ...
0
votes
1answer
81 views
Multiple Choice on Linear Regression
1. Which one is NOT a linear regression models? Please give a 1-2 sentences brief
explanation to your choice.
(a) $y_i = β_0 +\exp(β_1x_i)+E_i, i = 1, 2, \ldots, n$
(b) $y_i = β_0 + β_1x_i + β_2 ...
2
votes
0answers
37 views
SVM classifier (with soft-margin) implementation in R, gamma value and quadprog
I'm trying to implement a Support Vector Machine classifier in R and I have to solve the optimization problem using the quadprog R package which solves problems of the form :
$$min_b \frac{1}{2} ...
1
vote
0answers
17 views
Using MatchIt to match groups in a retrospective analysis
I am interested in using the R package MatchIt to preprocess my data as to obtain matched groups based on a predefined treatment variable. However I am facing a few issues.
The first issue is that ...
3
votes
1answer
46 views
Hold-one-out linear regression : a shortcut?
For a series of observations $(\vec{x}_i, y_i), i = 1 \cdots N$ from the linear model $Y = \beta^T X + \epsilon$, the least squares estimate of $\beta$ is: $\hat{\beta} = (\mathbf{X}^T ...
3
votes
0answers
40 views
+50
Brant test in R
In testing the parallell regression assumption in ordinal logistic regression I find there are several approaches. I've used both the graphical approach (as detailed in Harrell´s book) and the ...
3
votes
2answers
112 views
Using lmer for repeated-measures linear mixed-effect model
EDIT 2: I originally thought I needed to run a two-factor ANOVA with repeated measures on one factor, but I now think a linear mixed-effect model will work better for my data. I think I nearly know ...
0
votes
2answers
55 views
How to forecast time series with the help of other training time series in R?
Consider such a task: I have the figures on last year's bookselling of a certain book store, and the information of the first half of this year too. Now I want to predict the figure at the end of this ...
0
votes
2answers
46 views
Time Series Similarity : Differing Lengths with R
I am experimenting with creating a distance matrix between time series for clustering and similarity searching. The main reference I am using is for the Similarity procedure in SAS (Paper). I would ...
1
vote
0answers
55 views
EM algorithm for Gaussian mix
Can anyone help me with the R code to implement EM algorithm. I got different value if I chose different starting value; clearly this is not good. And the value of $\mu$, $\sigma$ goes to NA after ...
2
votes
0answers
17 views
Non-integer dependent variable in negative binomial models
I have non-nested count data that I've interpolated from one area to another based on the proportion of the area that lays in each. This is ZIP codes to counties, so most nest cleanly, with a few ...
0
votes
1answer
29 views
Specifying multiple (separate) random effects in lme
I was working in R packages nlme and lme4, trying to specify the models with multiple random effects. I found, that only nlme allows to specify the heterogeneous structure of the variance. Therefore, ...
2
votes
1answer
46 views
Change in binomial proportion confidence interval
I'm having trouble calculating 95% confidence intervals for a change in binomial proportion. For example, in group $A$, there are $4$ successes out of $n =20$. In group $B$, there are $12$ successes ...

