Use this tag for any *on-topic* question that (a) involves `R` either as a critical part of the question or expected answer (b) is not *just* about how to use `R`.

learn more… | top users | synonyms

0
votes
0answers
14 views

PCA Algorithm & Residual in R

I'm studying PCA algorithm.But I meet a problem about the residual! I did the same as this manual until step 5. From step 6, I don't quite understand its idea as the dimensions of Y and Yhat are ...
0
votes
0answers
6 views

Quantifying importance of environmental variables in Canonical Correspondence Analysis using R?

I currently have species abundance data for multiple lakes along with measurements of some environmental variables for each lake. I decided to do Canonical Correspondence Analysis of the data in R, as ...
5
votes
0answers
12 views

Kaplan Meier estimate for data with unequal numbers in treatments

Is it possible to estimate Kaplan-Meier medians, CIs and difference with unequal sample size in treatments or do I have to do coxph? For example, in my dataset, ...
1
vote
0answers
8 views

Specification of partially crossed longitudinal subjects in linear mixed effects model (lme4, lmer)

I am familiar with linear regression models, but I am in the process of learning about linear mixed effects models. My data consists of measurements for each month for a set of subjects over a long ...
0
votes
0answers
8 views

How to rescale “linear predictor” in drawing nomogram with “rms” package in R? [migrated]

I am trying to draw a nomogram from a logistic regression in R by using the rms package, but currently I have a problem: indeed, I can get the nomogram, but the "linear predictor" axis ranges from ...
1
vote
2answers
25 views

How to interpret decomposition plot and check for seasonality

I'm new to this and I have a question about the results that I get from checking whether my data contains seasonality or not. I have a csv file which contains date, period and year. However, R reads ...
2
votes
0answers
20 views

Monte Carlo choice of sample size

If I have $U_1,U_2,... \sim i.i.d~~ \text{Uniform}(0,1)$, and $f(x) = \sqrt{1-x^2}$. Then, by the Strong Law of Large Numbers: $$ P \left( \bigg{\lvert} \frac{1}{n}\sum_{k=1}^nf(U_k)-\int_0^1f(x)dx ...
1
vote
1answer
19 views

Interpretation of model comparison with random slopes using lmer in R

I have a large data set with repeated measurements of same blood value (co) (2 to 7 measurements per patient). Each measurement is coupled with time which is the time interval between surgical ...
2
votes
2answers
43 views

Singular value and eigen-decomposition of a square symmetric matrix should be identical, but differ in sign

As far as I know, singular value decomposition (SVD) and eigendecomposition give the same result for symmetric square matrices. But when I check the results in R, that's not what I see. Please see ...
1
vote
1answer
28 views

Interpreting the result of decomposing time series

I don't have a lot of experience working with time series data. Now I have a 3 year, monthly data for several entities (you can think about them as different stores), that I would like to do some ...
1
vote
3answers
36 views

Difference between rexp and qexp in R

I need to write a simulation that requires the use of exponential distribution. I was wondering what is the difference between the following two approaches in drawing random numbers from an ...
0
votes
0answers
16 views

Interpretation results seasonality in data R

I have a question about the results that I get from checking whether my data contains seasonality or not. I have a csv file which contains date, period and year. However, R reads the date as a factor ...
0
votes
0answers
21 views

Non linear optimization in R [on hold]

I am working on a non linear optimization problem and the packages I have been trying to use are alabama Rsolnp and nloptr. But in each case I seem to be getting the same kind of error where I am ...
0
votes
0answers
24 views

Understanding lm() function in R with weights

Consider the following simplified dataset (sales and percent of color-type sales by region): ...
0
votes
0answers
17 views

Input EGARCH model (idiosyncratic volatility)

I have a time-series of historical volatility observations. I want to use an EGARCH model because I believe it is a better representation of the behaviour of these volatilities. Can I estimate an ...
0
votes
0answers
6 views

Is it possible to apply a weight against multiple attributes in Rattle?

Hi I'm trying to figure out how to apply weight to multiple attributes in Rattle. I'd basically like SVM or random forest models to give greater weighting to ...
0
votes
0answers
21 views

KS, RMSE tests in R

I have a set of yearly peak river flows and I am trying to use the KS test to conclude if the data is coming from a generalized extreme value (GEV) distribution. I am also trying to calculate a root ...
1
vote
0answers
40 views

Lme4 and lmertest: Different degrees of freedom from same dataset

I just encountered a problem while analyzing experimental data using lme4 and lmertest. In the experiment, 67 subjects gave 3 ratings for 50 stimuli shown for 3 different durations (a total of 10050 ...
0
votes
0answers
16 views

Contrast 3 is orthogonal to Contrast 1, Contrast 2

The question is using orthogonal contrast: 4 different paint (1,2,3,4) surface with 2 levels(Asphalt, concrete) for contrast 1: I would like to compare paint 1 and paint 2 for contrast 2: I would ...
1
vote
1answer
22 views

Plotting a ECDF in R and overlay CDF

I need to plot a ECDF in R and overlay a CDF. In my case I have to do this with the gamma distribution where alpha = 2, ...
0
votes
0answers
27 views

How to get the most important variables in random forests in R?

I am building a random forest in R and was wondering how to extract the most important variables. I am using a random forest to classify if a click is fraud or not, and the goal is to identify ...
0
votes
0answers
9 views
0
votes
0answers
14 views
+50

factorial analysis of 2 quantitative + 2 qualitative - inconsistent results

I have a dataset composed of 4 variables, 2 being numerical and 2 categorical (ordinal in fact). They all represent 4 types of indicators/measures of the same phenomenon . I want to analyse them in a ...
1
vote
0answers
7 views

Leave-one-out cross validation with bayesian networks - R

I have a dataset with 1000 rows and 10 columns and s/n values. The head of the data : ...
4
votes
1answer
23 views

How to find factor that is making matrix singular

I have a 300+ column data.frame, and no matter how I break it up I get this error every time: ...
4
votes
3answers
55 views

Interpreting random effect variance in glmer

I'm revising a paper on pollination, where the data are binomially distributed (fruit matures or does not). So I used glmer with one random effect (individual ...
0
votes
1answer
15 views

How to implement knn in r with missing values?

I have this data set from https://archive.ics.uci.edu/ml/machine-learning-databases/credit-screening/crx.names which gives a good summary of the attributes im using. Some of the observations are ...
1
vote
1answer
10 views

Combining text and non-text features

I am working on a binary classification problem using SVM. I am currently using ksvm in R (kernlab package). The input is a combination of text and scores. I would like to be able to use substring ...
5
votes
0answers
85 views

What's wrong with this visualization of eigenvalues/vectors/PCA?

I have a dataset of 17 people, ranking 77 statements. I want to extract principal components on a rotated correlation matrix of correlations between people (as variables) across statements (as ...
2
votes
0answers
26 views

Finding the optimal combination of independent variables for a constrained dependent variable

I'm currently working on power plant time series data and my main objective is finding out the optimal combination of independent variables which would keep "SO2 concentration (dependent variable) ...
0
votes
0answers
18 views

Find sample size of all interactions for cross classification GLM in R [on hold]

Suppose that I have a response variable called A and four explanatory variables that are all factors (all with at least 3 levels) called B, C, D, and E. I know that the total sample size of my data is ...
0
votes
0answers
12 views

Confidence interval for the difference of two proportions from small sample size

Suppose I have two trials with small sample sizes such that the event rate for the first trial is $p_1=2/25=0.08$ and for the second trial $p_2=3/20=0.15$. I am wondering what may be the best way to ...
2
votes
1answer
61 views

Comparing models in linear mixed effects regression in R

I have a very large data set with repeated measurements of same blood value (co) (1 to 7 measurements per patient). Each measurement is coupled with time which is the time interval between surgical ...
0
votes
0answers
42 views

Non-linear regressions with caret package in R [on hold]

i'm new using R and my doubt is really basic. I have several dependent variables (x) and one independent variable (y), and I'd like to generate different regression models with ...
1
vote
0answers
16 views

calling R2OpenBUGS with Wine on Mac [on hold]

I really don't know where to go for a solution to this problem. This may not be the right place... I also tried stackoverflow but got no response. Any suggestions gratefully received. I'm trying to ...
1
vote
0answers
26 views

How to determine if a categorical variable affects an independent variable?

I am looking at the wine dataset from the R FactoMineRpackage to find out whether the categorical variable soil type affects the ...
1
vote
1answer
27 views

When is a Ljung-Box test significant?

I have trouble understanding the output of the Ljung-Box test due to conflicting information: The R documentation doesn't actually say how to interpret the output. This site states that small ...
2
votes
1answer
192 views

Negative-binomial why the answer is 0.288?

In a negative-binomial experiment with three independent trials, if I want the probability for 2 successes before the first failure. The probability of each trial is 0.6. ...
1
vote
0answers
14 views

Intercept in glmnet

I am trying to fit a regularized logistic regression to my data using glmnet. Using $\alpha=1$ I get a LASSO-regression, which is what I want. My problem is though that I don't know how the intercept ...
0
votes
0answers
18 views

Quantile regression prediction in r

When I call predict.rq function, it returns a matrix which stored different predictions when in different quantiles. But I only need exactly one number for each ...
0
votes
0answers
9 views

Define Data in R [on hold]

I have a data file with one column and 1000 row. I want to label each value in my data so I can call it if I want it. For example, if I name my data with C then I want to use the first value (c_1) or ...
0
votes
0answers
32 views

Curve fitting in R

I had 4 groups of data (in color 1 to 4) and one group is the data for one day, so I had 4 days of data. I was trying to fit a line which describes the pattern of theses lines (oscillating pattern) ...
3
votes
1answer
38 views

Spatial autoregressive model implementation in R

I need to implement a SAR model with no covariates. To be more specific, the regression I have to estimate is y=bWy+e where: y is the dependent variable; b is the coefficient parameter to be ...
0
votes
0answers
31 views

Arraning arriving Trains as good as possible to minimize the number of Tracks needed [on hold]

The problem I like to solve is very similar to the following: There are a number of trains arriving at different times, and staying for different duration at a rail station. e.g.: Train 1 arrives ...
0
votes
1answer
17 views

Does there exist an algorithm/package in R that tells if a matrix is aperiodic? [on hold]

I am currently reading Golub and Jacksons paper "Naïve learning in social networks and the wisdom of crowds" published in the American Economic Journal: Microeconomics in 2010. On page 120 they say ...
2
votes
2answers
29 views

R: how to interpret mosaic and association plots

I'm using the mosaic and assoc functions in the library vcd. My mosaic plot is as follows: ...
1
vote
0answers
36 views

Linear regression - Simulation - “what if” scenario

I have an assignment at university and I have been given a simple situation which I would like to explain here. Situation: I would like to perform simulation on purchase price of a product and see ...
0
votes
0answers
18 views

How to fit intensity peaks from a image?

I have a image - that I can convert to a txt/table with all intensities. In this image, several regions show higher intensity, i.e. a peak. A peak may be stored in a 10x10 matrix with rows and colums ...
2
votes
0answers
8 views

Forecast Function for Historical Data (Fitted Values)

I am fairly new to R so my data manipulation experience isn't as strong as it is with other software packages. I have been primarily using the high level functions that others have written. The ...