I thought I would start to write the basic of modelling so that I don’t forget how difficult it is for someone with no knowledge of what it is and the challenges they face and also the highly rewarding learning experience that coding can be.

My aim is to avoid jargon and reduce the scariness that modelling and coding can cause. Think of it like having a instant messaging conversation with your computer.

**What is modelling/coding/ writing algorithms?**

Many people will switch off as soon as someone says I used an algorithm, because it seems over peoples heads but all it is, is a set of instructions that you want a computer to do. It is a set of steps that calculate stuff. It can be used for many things from calculation, data processing, and automated reasoning.

**First rule never be scared to question what you don’t understand **

**Modelling is all about getting it wrong until you get it right**.

When modelling keep this in mind **“***Everything should be made as simple as possible, but not simpler*.” -Einstein

*(I will write mainly in R code but will try also to give the basics in C and Matlab to show comparatives in languages which are very similar to translating from Brazilian Portuguese to Spanish to Portuguese, they are based on similar foundation.)*

**The beginning: The black box**

Firstly I am assuming you have R download from (http://www.r-project.org/)

Open R when load you should get this Screen

The little red mark is where you type you instruction for what you want R to do.

Say I want x to equal 100. I type “x<-100”. The “<-” means equals “=”. You can uses = but R like the arrow equals version best. Its best to start good habits early. Then press enter, you have told R that you want x to mean 100 and it will remember this. Unless you assign x to a different value later that would then become the new meaning of x. Always remember to use different letters for different pieces, as it can get confusing and you may cause R confusion later on.

If you now call “x” by typing it and pressing enter. R will show you x’s value of 100

R can also create a string of numbers attached together, say you want x to equal 1 and 5 and 7 together but not added or summed in any way.

How you do this is by typing “x<-c(1,5,7)”. The “c” means concatenate (meaning group together). Press enter and call x and x will now be a string of 1,5,7

### Like this:

Like Loading...