Y los pesos dados por
Da el valor de \(\mu\) que minimiza la ecuación de los mínimos cuadrados
\(\sum_{i=1}^n =w_i(x_i-\mu)\)
x <- c(0.80, 0.49, 0.58, 0.77, 0.36, 0.55, 0.54, 0.83 , 0.42, 0.41)
y <- c(1.39, 0.78, 1.57, 0.46, 1.15, -1.54, 1.23, -0.62, 1.41, 0.01)Ajuste la regresión a través del origen y obtenga la pendiente y como variable dependiente y a x como variable independiente.
Cargue el conjunto de datos mtcars \(data(mtcars)\) y ajuste el modelo de regresión con mpg como dependiente y peso como independiente. Interprete los coeficientes
| # | Var | Description | Comments |
|---|---|---|---|
| 0 | name | Model of Vehicle | The car types are a mix that includes sedans (Datsun, Ford, Honda,…), luxury sedans (Mercedes, Cadellac,..), muscle cars (Javelin, Challenger, Camero…) and high-end sports cars (Porsche, Lotus, Maserati, Ferrari…) |
| 1 | mpg | Miles/US Gallon | mpg is the determinant of fuel efficiency |
| 2 | cyl | Number of cylinders | Data includes vehicles with 4,6,8 cylinder engines. |
| 3 | disp | Displacement (cu.in.) | Displacement measures overall volume in the engine as a factor of cylinder circumfrance, depth and total number of cylinders. This metric gives a good proxy for the total amount of power the engine can generate. |
| 4 | hp | Gross horsepower | Gross horsepower measures the theoretical output of an engine’s power output; notably, gross rating is of the engine in an isolated environment outside any specific vehicle. When installed in a car, exhaust systems, carburetor, alternator, power systems, etc all influence the power that actually gets to the drive train. Moreover, according to online sources, in the early 1970s, regulatory changes influenced how gross horsepower was measured. As this dataset is from the early-mid 1970s, it’s unclear if hp metrics may be used as reliable comparators of engine power across models as it’s uncertain how manufacturers are reporting. |
| 5 | drat | Rear axle ratio | The rear axle gear ratio indicates the number of turns of the drive shaft for every one rotation of the wheel axle. A vehicle with a high ratio would provide more torque and thus more towing capability, for example. Transmission configuration can often influence a manufacturer’s gearing ratio. |
| 6 | wt | Weight (lb/1000) | The overall weight of the vehicle per 1000lbs (half US ton) |
| 7 | qsec | 1/4 mile time | A performance measure, primarily of acceleration. Fastest time to travel 1/4 mile from standstill (in seconds). |
| 8 | vs | V/S | Binary variable signaling the engine cylinder configuration a V-shape (vs=0) or Straight Line (vs=1). V==0 and S==1. Configuration offers trade offs in power/torque, design usage in terms of space/size of engine and performance or center of gravity of vehicle. The geometry and placement of the engine, as influenced by its cylinder head, can have numerous knock-on influences on the vehicle beyond the technical engineering considerations of the cyliner angle. |
| 9 | am | Transmission Type | A binary variable signaling whether vehicle has automatic (am=0) or manual (am=1) transmission configuration. |
| 10 | gear | Number of forward gears | Number of gears in the transmission. Manual transmissions have either 4 or 5 forward gears; Automatic either 3 or 4 |
| 11 | carb | Number of carburetors | The number of carburetor barrels. Engines with higher displacement typically have higher barrel configuration to accomodate the increased airflow rate of the larger engine; in other words, more capacity is available for an engine when it may need it versus constraining power output with limited barrels. A vehicle may have multiple physical carburetors, but it’s less common; this metric is the sum of the number of carburetors and the number of barrels inside the carburetor. |
## (Intercept) wt
## 37.285126 -5.344472
Considere los siguientes datos
¿Cuál es el valor de x si se normalizó (media de 0 y varianza 1), interprete?
## [1] 0.4603863 0.3617321 1.0303884 -1.5894289 -0.2630779
Ajuste la regresión del punto 3 con las variables estándarizadas, interprete los parámetros de esta regresión.
x<-mtcars$wt
y<-mtcars$mpg
m_x <- mean(x)
sd_x <- sd(x)
nor_x <- (x - m_x) / sd_x
m_y <- mean(y)
sd_y <- sd(y)
nor_y <- (y - m_y) / sd_y
regr_line <- lm(nor_y ~ nor_x)
coef(regr_line)## (Intercept) nor_x
## 8.052569e-17 -8.676594e-01
Sabes que tanto el predictor como la variable respuesta tienen una media de 0. ¿Qué puede decir del intercepto cuando se ajusta una recta de regresión?
Considere el siguiente conjunto de datos
¿Qué valor minimiza la suma de las distancias al cuadrado entre estos puntos y dicho punto?