# Regression: very basic questions [closed]

I am about to implement the regression. Since I am analyzing on my own, and have almost zero practical know-how of statistics, I doubt myself a lot (plus the results I have obtained so far look 'weird'), hence it would be great if you could take time to validate whether what I am doing makes sense.

I have recorded human EEG activity (EEG signal) via 50x50 electrode array while performing 3 different, separate force tasks (force recorded by force sensors). Now I want to check if it is feasible to predict exerted force for all of the tasks from the signal, by using linear regression - i.e., my predictor variable is the signal feature, and my response variable is the force. The purpose of the analysis is prediction for the control of robotic devices.

I started with calculating RMS in a window of 100ms, centered around the activity spike detected in the signal; I calculated the RMS for all of my spikes detected in all of the electrodes, so as the result I obtained a matrix of 50xn (where n is the number of spikes detected) RMS values. Now, I want to use this RMS as a feature for my regression.

I am using Matlab as my software. With that, I have read that if I just want to see the simple line (fit) of regression, I should use scatterplot - so I do that. My inputs for the scatterplot(x,y) are two vectors: x is my independent variable - concatenated vector with all of the RMS values from all of the electrodes, and y is a dependent variable - i.e. force vector. During one task, I obtain the force recording for all of the 3 possible forces, but I am interested in just one - therefore as my y I use interpolated force recording only from row 1 of my 3-rowed matrix of forces recorded during one task. Is that correct? The results of that look kind of weird, i.e. I obtain two clusters and I do not really understand why:

I read that in similar cases some researchers were using simply a vector of 0s and 1s as a force vector, i.e. they would concatenate the 3 force rows obtained from one task recording, and instead of actual values, input 1s for the 'force' of the degree of freedom that was supposed to be active during this task, and 0s for the other degrees of freedom. If I try to do it, my plot absolutely doesn't make sense.

Additionally, I tried to obtain a linear regression model for my data, so I used a function fitlm in Matlab: mdl = fitlm(X,y) which returns a linear model of the responses y, fit to the data matrix X. As my X I input nx50 matrix of my RMS I described earlier (only these dimensions would work with the input; should I change that?), and as my y - a vector of 1 activated-degree of freedom-force recording, interpolated linearly to the length of n; in this case, n=807. The model plot is similar to scatterplot, and I am not really sure how to interpret the results I obtain:

mdl =

Linear regression model:
y ~ [Linear formula with 51 terms in 50 predictors]

Estimated Coefficients:
Estimate          SE          tStat        pValue
___________    __________    _________    __________

(Intercept)         2.0358       0.40881       4.9798    7.9229e-07
x1               0.0002986     0.0018282      0.16333        0.8703
x2               0.0011608     0.0018329      0.63332       0.52672
x3              -0.0006957     0.0014842     -0.46872       0.63941
x4               0.0005773     0.0019618      0.29428       0.76863
x5              -0.0014016     0.0016736     -0.83748       0.40259
x6               0.0008415     0.0021559      0.39032       0.69641
x7               0.0023311     0.0021785         1.07       0.28495
x8              -0.0010117     0.0014618     -0.69211       0.48909
x9              -0.0013399     0.0018555     -0.72216       0.47042
x10             0.00037971     0.0015525      0.24458       0.80685
x11             -0.0011698     0.0021935     -0.53333       0.59396
x12             0.00090134      0.002039      0.44204       0.65859
x13              0.0007281     0.0019253      0.37817       0.70541
x14               -0.00176     0.0023688     -0.74302       0.45771
x15             -0.0001714    0.00015333      -1.1178         0.264
x16            -0.00081656     0.0021379     -0.38194       0.70261
x17             0.00028961     0.0022877      0.12659        0.8993
x18             0.00034583     0.0025499      0.13563       0.89215
x19             0.00096935     0.0027414      0.35359       0.72374
x20             -0.0014632     0.0023052     -0.63474        0.5258
x21            -0.00011716     0.0020946    -0.055934       0.95541
x22            -4.3298e-05     0.0015385    -0.028142       0.97756
x23                      0             0          NaN           NaN
x24             0.00087342     0.0017931       0.4871       0.62633
x25            -0.00016198     0.0017182    -0.094271       0.92492
x26               0.001866     0.0028545      0.65372        0.5135
x27             -0.0041428     0.0030668      -1.3509       0.17715
x28              0.0040645     0.0026273        1.547       0.12228
x29            -0.00034988     0.0015693     -0.22296       0.82363
x30              0.0013504     0.0017023      0.79331       0.42785
x31             -0.0025312      0.001922      -1.3169       0.18827
x32             0.00028483      0.003016     0.094437       0.92479
x33             0.00022888     0.0035227     0.064971       0.94821
x34              0.0027619     0.0035508      0.77781       0.43693
x35             0.00011421     0.0020253     0.056392       0.95504
x36             -0.0025744     0.0029528     -0.87185       0.38357
x37             0.00061687     0.0032126      0.19201       0.84778
x38            -0.00046412     0.0031713     -0.14635       0.88368
x39              0.0011324     0.0034385      0.32933         0.742
x40              0.0026773     0.0033099      0.80887       0.41885
x41              -0.002997     0.0034798     -0.86124       0.38938
x42             6.2557e-05     0.0019034     0.032866       0.97379
x43            -3.9703e-05     0.0023244    -0.017081       0.98638
x44             0.00052333     0.0027785      0.18835       0.85065
x45                      0             0          NaN           NaN
x46            -0.00076091      0.002463     -0.30894       0.75745
x47             -0.0024118      0.003266     -0.73847       0.46046
x48                      0             0          NaN           NaN
x49             -0.0011203     0.0027911     -0.40137       0.68826
x50             0.00048973       0.00171      0.28639       0.77466

Number of observations: 807, Error degrees of freedom: 745
Root Mean Squared Error: 0.649
F-statistic vs. constant model: 0.653, p-value = 0.981


Does the high number of intercepts even make sense? Should I plot things differently? And what is your take on the two weird clusters I obtain? Is my understanding of things wrong?

Thanks in advance for your help, as you can see I am quite confused with something simple.

• This question is long and complex - it's got a lot of details that don't matter for the statistics. It also asks a lot of questions. You're more likely to get good answers if you can ask one simple question at a time. – Jeremy Miles Jul 10 '18 at 8:04
• You only have one intercept. Other than that, it's pretty unclear what all the x's are; you say you have 50 of them, but you show 24; the only one that really looks weird is x23, but without the data it's hard to know why that is 0. It might be all missing. The plot does look odd, but you might need to hire a consultant to figure it all out. – Peter Flom Jul 10 '18 at 11:34

R-squared: 0.0508, Adjusted R-Squared -0.027 F-statistic vs. constant model: 0.653, p-value = 0.981

Here you have a good summary of how your model is doing.

R-squared should be close to 1 for a model to be "good", in a linear manner (more on that later), so your model is doing pretty terrible. But that doesn't necessarily mean that your X aren'r related with your y, simply linear regression is not a good "fit".

p-value this is a value you get from a Statistic test that tests a comparison between your model and a costant model (a really dummy model), if it's a value close to zero (typically below 0.05), your model is performing better than a dummy model (it's like "at least I'm better off with my model than a simple costant"). As you can see that's not the case unfortunately.

Just these two values should point out pretty easily how are you doing. Also the red line on your plot shows that we are not fitting quite good the blue points.

Probably a linear model is not the case here, so here's your option if you still want to do regression: Logistic Regression.

Logistic regression is actually pretty used when you have a responde (y) that takes two values 0 or 1. Luckily a lot of statistical softwares implement it easly, so you'll have no problem finding examples even for Matlab.

• Thanks for help, Riccardo. I have realized that I have been inputting as my matrix a modification to what I actually wanted - after the correction, my R-squared is equal to 0.67, with p-value 3.47e-26. I guess thats better. One more silly question: should I believe such results even if my scatterplot does not look 'typically' linear? – Forthal Jul 9 '18 at 9:39
• It mostly depends on want you want to achieve. 0.67 is low, but you can see from your plot that the data is not linear, so that's that. Probably you can do some feature extraction and remove some non relevant predicotrs, and get a better R2, but it won't improve much from 0.67, again your data is not linear, it hardly ever is. – RLave Jul 9 '18 at 9:44
• If you just need the model to understand the relationship between Xs and y, then you can use this model, because linear regression has the advantage of easy interpretation. – RLave Jul 9 '18 at 9:45
• Yup, basically I need to find a right model to model the relationship between Xs and ys. I will try with logistic regression now, thanks! – Forthal Jul 9 '18 at 11:26