Multiple Linear Regression_1

Hello,
I wanted to get help from someone who can aid me throughout a statistical issue. I wanted to write a multiple linear regression and for that I've got into a problem.
Thank you ever so much.

The standard R function for a multiple regression is lm().

Past that, you might want to give more detail on what you're trying to do, you've done, and what the problem is.

hello, thank you, honestly, I know it but the problem is that I want to write a mlr on my data sets, which contain some features, how can I write 1 feature with 4 features of the other data set?
for example: I want to write a multiple linear regression with the peak 1 of node 37 vs [peak 1, peak 2, t1, t2]
and is there any possibility to share my data sets here?

Ideally, you should provide a proper REPRoducible EXample (reprex) illustrating your issue that includes sample data in a copy/paste friendly format.

Adding to what @andresrcs says, you can use dput() to make an easy copy-paste version of your data. If your data is very large, you might want to just post a subset.

Also, remember that no one here knows the context of your data. We don't know what a "feature" is or what a "peak" or a "node" is. Showing us how the data is organized, even if it's not all the observations, will help a lot.

thank you so much, well, you are completely right and I'm going to share it here

@startz sorry, but how can I use dput()?

Suppose the data frame for your regression is called df. Give the command

dput(df)

And copy and paste the output here.

If the data frame has too many rows, you might just put up a sample of your data with

dput(head(df,100))

thank you so much;
peak1
[1] 672.0 612.0 432.0 660.0 660.0 900.0 684.0 564.0 672.0 708.0 624.0 540.0 612.0 708.0 456.0
[16] 432.0 600.0 672.0 588.0 624.0 576.0 483.0 732.0 744.0 684.0 660.0 600.0 696.0 528.0 432.0
[31] 684.0 636.0 456.0 636.0 600.0 516.0 516.0 684.0 648.0 564.0 420.0 660.0 732.0 564.0 636.0
[46] 536.0 744.0 792.0 756.0 624.0 372.0 672.0 696.0 756.0 576.0 672.0 552.0 408.0 684.0 720.0
[61] 768.0 465.0 489.0 588.0 696.0 696.0 732.0 528.0 516.0 672.0 612.0 504.0 396.0 648.0 612.0
[76] 744.0 684.0 528.0 396.0 624.0 600.0 648.0 612.0 504.0 432.0 708.0 708.0 540.0 600.0 624.0
[91] 480.0 552.0 600.0 462.0 372.0 348.0 270.0 294.0 282.0 300.0 384.0 468.0 330.0 318.0 366.0
[106] 396.0 378.0 414.0 348.0 315.0 354.0 456.0 408.0 354.0 366.0 348.0 276.0 306.0 366.0 396.0
[121] 252.0 354.0 288.0 516.0 342.0 468.0 480.0 384.0 300.0 420.0 426.0 624.0 480.0 462.0 372.0
[136] 268.5 468.0 456.0 558.0 432.0 504.0 540.0 324.0 456.0 480.0 516.0 456.0 492.0 390.0 468.0
[151] 450.0 384.0 462.0 540.0 450.0 450.0 450.0 504.0 516.0 384.0 396.0 426.0 474.0 474.0 414.0
[166] 510.0 274.0 291.0 486.0 288.0 456.0 360.0 351.0 510.0 492.0 450.0 360.0 456.0 294.0 288.0
[181] 354.0 402.0 312.0 480.0 295.5 348.0 450.0 384.0 348.0 289.5 456.0 480.0 400.5 450.0 480.0
[196] 492.0 492.0 426.0 486.0 366.0 310.5 480.0 480.0 414.0 444.0 468.0 426.0 282.0 456.0 534.0
[211] 492.0 450.0 480.0 354.0 312.0 522.0 486.0 414.0 244.0 486.0 456.0 474.0 384.0 444.0 342.0
[226] 283.5 432.0 486.0 456.0 300.0 210.0 588.0 438.0 480.0 438.0 294.0 354.0 288.0 270.0 510.0
[241] 420.0 271.5 420.0 510.0 522.0 444.0 390.0 306.0 384.0 438.0 522.0 456.0 438.0 522.0 462.0
[256] 474.0 414.0 456.0 408.0 276.0 240.0 192.0 300.0 288.0 312.0 216.0 192.0 276.0 264.0 288.0
[271] 222.0 312.0 288.0 312.0 336.0 288.0 288.0 288.0 312.0 300.0 264.0 276.0 228.0 252.0 252.0
[286] 204.0 312.0 312.0 300.0 276.0 276.0 252.0 324.0 396.0 372.0 312.0 240.0 264.0 276.0 300.0
[301] 252.0 276.0 288.0 252.0 240.0 252.0 264.0 228.0 204.0 252.0 204.0 264.0 324.0 276.0 324.0
[316] 288.0 252.0 276.0 276.0 300.0 300.0 276.0 252.0 360.0 276.0 300.0 288.0 264.0 216.0 288.0
[331] 264.0 312.0 240.0 228.0 192.0 300.0 336.0 276.0 180.0 288.0 324.0 324.0 288.0 288.0 300.0
[346] 312.0 312.0 204.0 192.0 252.0 300.0 300.0 264.0 288.0 432.0 384.0 216.0 216.0 480.0 432.0
[361] 324.0 264.0 432.0 492.0 420.0 228.0 684.0 348.0 240.0 264.0 288.0 312.0 336.0 216.0 228.0
[376] 276.0 168.0 264.0 192.0 216.0 264.0 228.0 204.0 228.0 228.0 168.0 204.0 456.0 372.0 288.0
[391] 324.0 204.0 228.0 312.0 336.0 348.0 312.0 300.0 228.0 183.0 288.0 312.0 252.0 204.0 192.0
[406] 288.0 348.0 252.0 204.0 288.0 336.0 288.0 240.0 240.0 456.0 216.0 264.0 240.0 192.0 264.0
[421] 360.0
here is my data and I wanted to find a peak from here and write a MLR for it with the other data

Thanks for the data but it is not in dput() form. Here is a very simple example

Create some mock data and use dput()

dat <- data.frame(xx = 1:10, yy = letters[1:10])

dput(dat)

This outputs

 structure(list(xx = 1:10, yy = c("a", "b", "c", "d", "e", "f", 
"g", "h", "i", "j")), class = "data.frame", row.names = c(NA,  -10L))

which one then copies and pastes into the post.

thank you for your help,

c(672, 612, 432, 660, 660, 900, 684, 564, 672, 708, 624, 540,
612, 708, 456, 432, 600, 672, 588, 624, 576, 483, 732, 744, 684,
660, 600, 696, 528, 432, 684, 636, 456, 636, 600, 516, 516, 684,
648, 564, 420, 660, 732, 564, 636, 536, 744, 792, 756, 624, 372,
672, 696, 756, 576, 672, 552, 408, 684, 720, 768, 465, 489, 588,
696, 696, 732, 528, 516, 672, 612, 504, 396, 648, 612, 744, 684,
528, 396, 624, 600, 648, 612, 504, 432, 708, 708, 540, 600, 624,
480, 552, 600, 462, 372, 348, 270, 294, 282, 300, 384, 468, 330,
318, 366, 396, 378, 414, 348, 315, 354, 456, 408, 354, 366, 348,
276, 306, 366, 396, 252, 354, 288, 516, 342, 468, 480, 384, 300,
420, 426, 624, 480, 462, 372, 268.5, 468, 456, 558, 432, 504,
540, 324, 456, 480, 516, 456, 492, 390, 468, 450, 384, 462, 540,
450, 450, 450, 504, 516, 384, 396, 426, 474, 474, 414, 510, 274,
291, 486, 288, 456, 360, 351, 510, 492, 450, 360, 456, 294, 288,
354, 402, 312, 480, 295.5, 348, 450, 384, 348, 289.5, 456, 480,
400.5, 450, 480, 492, 492, 426, 486, 366, 310.5, 480, 480, 414,
444, 468, 426, 282, 456, 534, 492, 450, 480, 354, 312, 522, 486,
414, 244, 486, 456, 474, 384, 444, 342, 283.5, 432, 486, 456,
300, 210, 588, 438, 480, 438, 294, 354, 288, 270, 510, 420, 271.5,
420, 510, 522, 444, 390, 306, 384, 438, 522, 456, 438, 522, 462,
474, 414, 456, 408, 276, 240, 192, 300, 288, 312, 216, 192, 276,
264, 288, 222, 312, 288, 312, 336, 288, 288, 288, 312, 300, 264,
276, 228, 252, 252, 204, 312, 312, 300, 276, 276, 252, 324, 396,
372, 312, 240, 264, 276, 300, 252, 276, 288, 252, 240, 252, 264,
228, 204, 252, 204, 264, 324, 276, 324, 288, 252, 276, 276, 300,
300, 276, 252, 360, 276, 300, 288, 264, 216, 288, 264, 312, 240,
228, 192, 300, 336, 276, 180, 288, 324, 324, 288, 288, 300, 312,
312, 204, 192, 252, 300, 300, 264, 288, 432, 384, 216, 216, 480,
432, 324, 264, 432, 492, 420, 228, 684, 348, 240, 264, 288, 312,
336, 216, 228, 276, 168, 264, 192, 216, 264, 228, 204, 228, 228,
168, 204, 456, 372, 288, 324, 204, 228, 312, 336, 348, 312, 300,
228, 183, 288, 312, 252, 204, 192, 288, 348, 252, 204, 288, 336,
288, 240, 240, 456, 216, 264, 240, 192, 264, 360)

this is the dput format I guess

"this is the dput format I guess"

Yes. Thanks.

1 Like

what you provided is a single stream of numbers; a vector; if we consider a data.frame ( a tabular form) we would consider this to be a single variable / a single column of a table. It is impossible to do mlr from this.
reading back through your earlier posts; I would guess this is your peak1 variable. do you have other variables ?
do you have a data.frame ? do you not have a data.frame but have data on disk in some form ? csv is a common form; some people uses excel (xlsx).

1 Like

thanks to you for your help

yes you are right, I want to write a mlr for this variables and these ones:
c(648, 672, 480, 816, 744, 768, 744, 624, 708, 732, 792, 672,
744, 576, 540, 432, 636, 732, 648, 876, 552, 435, 708, 900, 804,
636, 660, 684, 600, 492, 708, 540, 504, 732, 720, 540, 543, 720,
708, 720, 510, 804, 708, 708, 708, 456, 684, 660, 624, 672, 468,
600, 660, 624, 648, 696, 600, 423, 816, 672, 708, 516, 471, 720,
828, 696, 708, 549, 624, 636, 636, 588, 528, 636, 660, 696, 732,
528, 444, 732, 684, 576, 696, 492, 504, 612, 684, 648, 684, 540,
420, 672, 612, 444, 516, 354, 309, 360, 294, 348, 396, 420, 426,
420, 408, 444, 492, 438, 360, 286.5, 396, 438, 390, 420, 378,
336, 294, 354, 420, 390, 318, 378, 336, 498, 378, 474, 516, 402,
378, 498, 660, 432, 486, 468, 408, 328, 456, 480, 426, 450, 576,
378, 352.5, 462, 492, 468, 486, 522, 444, 438, 468, 522, 420,
450, 504, 492, 510, 522, 468, 402, 376.5, 468, 480, 474, 450,
534, 285, 279, 468, 319.5, 450, 516, 444, 534, 456, 480, 438,
450, 468, 360, 450, 480, 378, 414, 270, 420, 462, 420, 396, 360,
570, 444, 349.5, 456, 468, 540, 462, 492, 450, 384, 355.5, 462,
444, 498, 504, 480, 444, 366, 444, 504, 432, 420, 492, 420, 360,
486, 504, 414, 360, 456, 438, 468, 450, 444, 438, 342, 486, 606,
450, 264, 252, 456, 480, 354, 438, 492, 312, 262.5, 396, 348,
384, 318, 336, 462, 444, 510, 408, 342, 510, 468, 528, 552, 432,
552, 444, 498, 456, 486, 480, 402, 231, 288, 300, 372, 372, 300,
240, 324, 312, 396, 240, 288, 348, 336, 348, 312, 300, 264, 324,
324, 324, 348, 204, 336, 300, 252, 360, 336, 348, 312, 360, 216,
312, 312, 372, 336, 336, 240, 324, 372, 408, 384, 312, 288, 300,
324, 276, 264, 300, 216, 216, 336, 336, 336, 324, 276, 324, 324,
312, 456, 408, 288, 312, 300, 336, 372, 264, 288, 264, 324, 288,
300, 336, 288, 264, 336, 312, 336, 348, 300, 492, 300, 300, 288,
276, 312, 288, 252, 336, 348, 300, 336, 288, 324, 468, 456, 309,
288, 480, 408, 420, 288, 348, 396, 408, 360, 480, 372, 300, 348,
336, 336, 456, 396, 288, 324, 276, 360, 312, 252, 468, 336, 336,
288, 312, 264, 228, 324, 336, 276, 336, 300, 276, 300, 300, 348,
324, 324, 288, 216, 300, 384, 324, 372, 264, 300, 312, 276, 312,
324, 312, 348, 312, 288, 288, 300, 324, 276, 228, 312, 336)

I copied your first post and named the data y. Then I copied the second post and named the data x. Then I gave the command

lm(y~x)

and got the results

Call:
lm(formula = y ~ x)

Coefficients:
(Intercept)            x  
     -2.255        0.934  

Is this where you're trying to get?

1 Like

well, actually, I want to write a mlr for 4 features, in that case I must use + sign to do this case?

you need a dataframe of 5 columns at least. do you have that ?

yes I have this one, but why it must be at least 5 columns?

A regression of 4 independent variables and 1 dependent variable is 5, but i may have misunderstood ehat you want to do. Feel free to explain.