File:Regression plane avec R.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 268 × 240 pixels, file size: 19 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description
Français : Régression linéaire à 3 dimensions avec GNU R (modifié avec Inkscape).
English: 3-demensional linear regression with GNU R (modified with Inkscape).
Date
Source Own work
Author Cdang
SVG development
InfoField
 
The SVG code is valid.
 
This chart was created with R.
 
 This file uses embedded text that can be easily translated using a text editor.
Source code
InfoField

R code

# Création des données

# nombre de valeurs de chaque variable explicative
n <- 5 

# variables explicative
x1 <- seq(0, 1, length.out = n) 
x2 <- seq(0, 1, length.out = n)

# répétition des valeurs pour mixer x1 et x2
x1.data <- rep(x1, each = n) 
x2.data <- rep(x2, n)

# variable expliquée
y = 1 + 2*x1.data + 3*x2.data + rnorm(n^2, 0, 0.4)

# ******************************
# régression des moindres carrés

donnees <- data.frame(x1.data, x2.data, y)
modele <- lm(y ~ ., donnees)

print("Modèle des moindres carrés : ")
print(modele)

# ************************
# représentation graphique

# tracé des données
VT <- persp(x1, x2, matrix(y, n, n))

# tracé des intersections du plan modèle
mx1 <- min(x1) ; mx2 <- min(x2)
Mx1 <- max(x1) ; Mx2 <- max(x2)
Minit <- trans3d(mx1, mx2, b0, VT)
Mzx <- trans3d(Mx1, mx2, fitted(modele)[n], VT)
Myz <- trans3d(mx1, Mx2, fitted(modele)[n*(n-1)+1], VT)

lines(c(Minit[1], Mzx[1]), c(Minit[2], Mzx[2]), lwd = 2)
lines(c(Minit[1], Myz[1]), c(Minit[2], Myz[2]), lwd = 2)

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current14:07, 27 August 2013Thumbnail for version as of 14:07, 27 August 2013268 × 240 (19 KB)Cdang (talk | contribs)better looking plot
13:51, 27 August 2013Thumbnail for version as of 13:51, 27 August 2013268 × 240 (19 KB)Cdang (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file:

Metadata