Sample Fortran Regression model for prediction of car prices

Can anyone share resources / links for building simple regression models for prediction of car prices using Fortran.

I’m curious what sort of data you would use as input to the model. It seems to me that there are many unknowable variables at work here. You might be interested in the observations at Trimflation: Explaining Why Automakers Raised Prices So Much In The Pandemic - The Autopian

processing of the data will be done using Python so they’ll all be numeric

That’s not what I meant - what sources of data would possibly be of prediction use here? Or is this just an academic exercise?

If you already have or want to write a likelihood function for your regression/predictions, then ParaMonte library offers the tools for stochastic optimization, sampling, and uncertainty quantification for the regression task. The documentation for the MATLAB and Python versions of the library has some simple to complex regression examples that might be helpful. A regression problem in Fortran/C/C++ using this library would be similarly solved.

Statistician Alan Miller wrote some Fortran codes for multiple regression, for example lsq.f90.

Unless your goal is to learn Fortran, I suggest using R or Python with pandas to do your regressions.

If you want to understand linear regression using Fortran: try this link: linear regression using Fortran. This provides the source code along with an example.

Basically, your objective will be:

Given an MxN matrix, A, and a Mx1 vector b, try to find a Nx1 vector, x, which minimizes the L2 norm (square root of the sum of squares of each component) of the residual
r (residual) = A * x - b

Alternatively, OP can simply use LAPACK.

@eikeakanam, because your post is a month old, you’ve probably already got the code for linear regression in Fortran… I’m late. :expressionless:

But my most honest answer would be that for a thousand of reasons you can’t make a prediction of car prices by the use of a simple regression model. Maybe we’re just talking of some academic exercise but this can’t be useful in the real world.

If you apply a linear regression to stock market prices predicting the next number (y_pred) in a sequence, you won’t get the future price but a somewhat counterintuitive thing:
y_pred > the_most_recent_price means that the price is currently in a downtrend.
y_pred < the_most_recent_price means that the price is currently in an uptrend.
No, this is not a typing error! This mechanism is very comparable to what we observe in the moving average widely used by traders.

Second, notice that we only get information about the current trend (up or down) but not the forthcoming price (in dollars). And there’s a 50% probability that this current trend is going to change right now! In conclusion, only by the use of a simple regression model we get nothing useful and can’t purchase Twitter. :slightly_frowning_face:

As I’ve said in my last post in the Forum, I’m currently working on AI models in Fortran. But note that it’s September now and my last post herein is from May when I was talking about months of past work. And now in September I’m still working on this… It took me several thousand hours of work to develop an early prototype of a Fortran code predicting the prices of the crude oil, and even this model can’t work with other commodities and stock market indices without certain modifications.

The point is that the real-world model you need to develop in order to know the future prices of cars is complex as hell. But yes, I still believe the Fortran is the best existing tool for this purpose! And linear regression is an obvious starting point. :wink: