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
2 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
0answers
6 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 ...
3
votes
0answers
41 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 ...
1
vote
0answers
14 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
16 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
9 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 ...
1
vote
1answer
37 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
29 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
15 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
23 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
24 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
185 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
13 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
17 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
28 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
23 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
28 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
16 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
25 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
28 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
17 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
5 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 ...
1
vote
0answers
13 views

Measuring effectiveness of marketing through attribution analysis

My data(dataframe in R) looks like this:The data is ordered by CustomerName and then TimeofEvent. ...
0
votes
0answers
9 views

Plotting multiple boxplots in one figure and include dotted line [on hold]

Take for simplicity following two vectors: ...
0
votes
0answers
16 views

Constrained optimization of non linear functions in R [on hold]

My objective is to maximize sales by reallocating my spend under certain constraints. For each key the sales is given by alpha*spend^beta. The total sales is the the sum of sales across all keys and ...
0
votes
1answer
41 views

Comparing datasets from 2 biological replicates

I have two datasets containing experiment data based on two biological replicates. I wonder what the best statistical methods are to find out and test how similar these two datasets are, and also how ...
1
vote
1answer
15 views

P-value from proportional hazards regression object [on hold]

I'm running some proportional hazards regression models using the survival package in r and would like to know how I can access ...
0
votes
0answers
12 views

Robust scoring to rank data

I am trying to develop a score for a dataset to rank (both numeric and categorical features, although I could just use numeric variables only as they are the more consequential ones) and would like to ...
-1
votes
0answers
25 views

Error in imputing data in R [on hold]

**i am imputing my data (all items) using VIMGUI package in R. But in the output section i am getting errors, which i am not able to understand, where the problem lies. The function which i run in R ...
0
votes
0answers
23 views

Zero inflated Poisson distribution [migrated]

Could someone help me in generating zero inflated Poisson data using R? thank you :) ...
0
votes
0answers
14 views

Quantitative or qualitative variable

Suppose I have a response variable $y$ and $p$ explanatory variables $x_1, x_2, \dots,x_p$. Suppose one explanatory variable is the month of the observation. Suppose that the variable "month" is ...
1
vote
0answers
12 views

How to force a division in tree and locate covariates that explain the variable in TraMineR?

my goal here is simple: I have a bunch of sequences, and a few sequences of interest (that do contain a certain subsequence). I want to force that division and use a tree method (either CART or ...
1
vote
1answer
15 views

How to do distance calculation and clustering for event sequences in TraMineR?

I've been using TraMineR for a while now, even though I consider myself a begginer user. The same goes for R language. Yet, I've been able to successfully perform a few optimal matching analysis. Now ...
0
votes
0answers
27 views

I'm in trouble while I'm estimating regression in R [on hold]

I try to estimate robust regression with R. But I am in trouble. I determine all variables. And I estimated regression with OLS (ordinary least square. I can do it. while I doing for robust, I ...
0
votes
0answers
26 views

How to plot the cumulative distribution function of std normal dist/smooth curve, step functions [on hold]

Look for “pnorm” and “pbinom” in help. Use these commands to plot the cumulative distribution function of the standard normal distribution (of parameters 0,1) and of binomial distributions of ...
0
votes
0answers
10 views

Which is the name of the R package that contains the box1way function? [on hold]

I need to perform a robust generalization of the Box test, but I do not know where it might be. I've just searched elsewhere on Internet with no succeed. Any ideas? Any other function/package where I ...
0
votes
0answers
20 views

rpart model has zero splits after using caret's train

I am using rpart to get a classification model for my data but I do not know how to allocate the bucket size so as to avoid getting an overfitted or underfitted model. To get the optimal bucket size, ...
0
votes
0answers
39 views

Bad results for R's auto.arima

I have a time series for sales data on a weekly and monthly basis. I tried using holt.winter and auto.arima. ...
0
votes
0answers
5 views

Mlogit for Rank-Ordered Logit - Troubleshooting [migrated]

I am trying to use the mlogit package to run a rank-ordered logit on my data. I had participants choose their top three out of 24 choices, and then rank them in order of preference. When I try to ...
1
vote
1answer
20 views

Starting-point of time-series influences regression?

I've used tslm() under the R-package fpp to analyse two time series, which seem similar: ...
0
votes
0answers
15 views

Prevalence ratio in Poisson regression for Binary response variable Using R

I have a data set on stunting (Height for Age) status of children and their socio-demographic information. If I want to find the socio-demographic determinants of stunting where dependent variable ...
0
votes
0answers
14 views

Finding AIC in a Holt-Winters Forecast [on hold]

I've recently come across a problem that I can't find any information on about how to solve it. I've got set of time series data and I've tried modeling it using 9-10 different models in R, using the ...
1
vote
0answers
13 views

Easiest way in R to get vector of frequencies of elements in vector [migrated]

Suppose I have a vector of values v. What is the easiest way to get a vector f of length equal to v, where the ith element of f is the frequency of the ith element of v in v? The only way I know to ...
0
votes
0answers
13 views

Beta Regression for Multilevel / Hierarchical Linear Models in any Statistics Package?

I would like to run a (if possible zero-one-inflated) beta regression in a multilevel model with three layers. So far I have not been able to find any programs or packages that would support such a ...
3
votes
0answers
24 views

R Fortran using rejection sampling in rtmvnorm() gives error

I'm sampling from a multivariate normal truncated distribution using rtmvnorm() function from tmvtnorm package in R. Using the ...
0
votes
0answers
4 views

Error in pred1.tree(tree, tree.matrix(nd)) : corrupt tree [on hold]

I get the following when running the cv.tree function from the tree package in R. Any ideas? ...
1
vote
0answers
10 views

How can i change the number of plots that R store? [on hold]

When I run a "for loop" to generate 172 plots, I can only watch the last 99 plots stored in plot box of R-studio. How can I increase this memory? I´m not interested in saving the plots, only watch ...
0
votes
1answer
11 views

Clarification on using train vs glm vs rpart for classification problems in R

I am using the glm function in R to perform logistic regression. I converted the outcome variable to a numeric between 0 <=y <= 1 as follows ...
-2
votes
0answers
16 views

Multiplying coefficient to get yhat

I am trying to build a model using this equation equation: yhat = b0*b1(x1)*b2(x2)*b3(x3) Most of the data are dummy variables and I can't used interaction ...